subject

Consider the following queue operations. If two threads are executing in parallel, and the first thread executes the enqueue one or more times, and the second thread executes the dequeue one or more times, is the implementation correct? Why or why not? You may assume that each line of code executes atomically, and that each line executes in the order in which it is listed in the code.

1 public void enq (Item x) {
2 if (tail-head capacity)
3 throw new Exception();
4 tail++;
5 items (tail % capacity] X;
6 }
7 public Item deq () {
8 if (tail == head)
9 throw new Exception ();
10 head++;
11 Item item = items (head % capacity];
12 return item; 13 } }

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:50
Explain why it is reasonable to assume that receiving 3 duplicate acks in tcp is an indication that the network is not currently congested.
Answers: 1
question
Computers and Technology, 22.06.2019 03:00
You install teamviewer on your workstation at home so that you can ac ess it when on the road. how can you be assured that unknown users cant access your computer through team viewer?
Answers: 2
question
Computers and Technology, 22.06.2019 18:00
Which of the following physical laws can make the flow of water seem more realistic? a. motion b. gravity c. fluid dynamics d. thermodynamics
Answers: 2
question
Computers and Technology, 23.06.2019 06:30
To become an audio technician, the most successful tactics might include the following. (select all that apply). learning how to persuade other people gaining different types of experience in audio technology learning as much as possible about art history establishing a reputation as a reliable professional
Answers: 1
You know the right answer?
Consider the following queue operations. If two threads are executing in parallel, and the first thr...
Questions
question
Mathematics, 19.09.2019 18:30
Questions on the website: 13722359