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 23:30
4.11 painting a wall (1) prompt the user to input integers for a wall's height and width. calculate and output the wall's area (integer). note that in this case there is a new line after each prompt. (submit for 1 point). enter wall height (feet): 11 enter wall width (feet): 15 wall area: 165 square feet (2) extend to also calculate and output the amount of paint in gallons needed to paint the wall (floating point). assume a gallon of paint covers 350 square feet. store this value in a variable. output the amount of paint needed using the %f conversion specifier. (submit for 2 points, so 3 points total). enter wall height (feet): 11 enter wall width (feet): 15 wall area: 165 square feet paint needed: 0.471429 gallons (3) extend to also calculate and output the number of 1 gallon cans needed to paint the wall. hint: use a math function to round up to the nearest gallon. (submit for 2 points, so 5 points total). enter wall height (feet): 11 enter wall width (feet): 15 wall area: 165 square feet paint needed: 0.471429 gallons
Answers: 3
question
Computers and Technology, 23.06.2019 17:00
The more powerful, 60 volt cables and the main power shut off on an hev are both colored orange
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
Lakendra finished working on her monthly report. in looking it over, she saw that it had large blocks of white space. what steps could lakendra take to reduce the amount of white space?
Answers: 3
question
Computers and Technology, 24.06.2019 22:00
Ican’t open these when it’s just a comment. someone pls explain why this is happening
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, 04.03.2021 14:00
question
Chemistry, 04.03.2021 14:00
question
Mathematics, 04.03.2021 14:00
question
Social Studies, 04.03.2021 14:00
question
Mathematics, 04.03.2021 14:00
question
Geography, 04.03.2021 14:00
question
Mathematics, 04.03.2021 14:00
Questions on the website: 13722362