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, 22.06.2019 16:30
Corey set up his presentation for delivery to his team.the information he had to convey was critical to their job performance.he knew he would need a lot of time to explain each point
Answers: 3
question
Computers and Technology, 23.06.2019 00:00
Which is the correct sequence of steps to set up a document in landscape orientation? a. select page setup from the file menu. then click the margins tab and select landscape. b. select page setup from the edit menu. then click the margins tab and select landscape. c. select page setup from the insert menu. then click the margins tab and select landscape. d. select page setup from the format menu. then click the margins tab and select landscape
Answers: 1
question
Computers and Technology, 23.06.2019 03:00
State 7 common key's for every keyboard
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
Apart from confidential information, what other information does nda to outline? ndas not only outline confidential information, but they also enable you to outline .
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, 05.03.2021 03:30
question
Mathematics, 05.03.2021 03:30
question
Mathematics, 05.03.2021 03:30
question
Physics, 05.03.2021 03:30
Questions on the website: 13722367