This exercise examines the queue implementation in Fig.3.14, whose enq()method does not have a single fixed linearization point in the code. The queue stores its items in anitems array, which, for...


This exercise examines the queue implementation in Fig.3.14, whose enq()method does not have a single fixed linearization point in the code. The queue stores its items in anitems array, which, for simplicity, we assume is unbounded. The tailfield is an AtomicInteger, initially zero. The enq()method reserves a slot by incrementing tail, and then stores the it e mat that location. Note that these two steps are not atomic: There is an interval after tail has been incremented but before the item has been stored in the array.The deq ()method reads the value of tail, and then traverses the array in as-cending order from slot zero to the tail. For each slot, it swaps null with the current contents, returning the first non-nullitem it finds. If all slots are null, the procedure is restarted.




May 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here