Question 6 What are the possible count outcomes of this pseudo-code: Given count=6 Thread 1(...) { Thread_2(...) { // do something // do something count++; count--; } Just put the correct values in the value column for each step to indicate how you get each count value if each of count++ and count-- can be executed in the following steps. Step Storage Value SO: Thread 1 execute register1 = counter register1 = S1: Thread 1 execute register1 register1 + 1 register1 = S2: Thread_2 execute register2 = counter register2 = S3: Thread_2 execute register2 = register2 -1 register2 = S4: Thread 1 execute counter = register1 counter = S5: Thread 2 execute counter = register2 counter =

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
icon
Related questions
Question
Question 7
What should the correct value of count be in the previous problem?
Transcribed Image Text:Question 7 What should the correct value of count be in the previous problem?
Question 6
What are the possible count outcomes of this pseudo-code:
Given count3D6
Thread_1(...)
{
// do something
Thread_2(...)
{
// do something
count++;
count--;
}
Just put the correct values in the value column for each step to indicate how you get each count value if each of count++ and count-- can be executed in the following steps.
Step
Storage
Value
SO: Thread 1 execute register1 = counter
register1 =
%3D
%D
S1: Thread 1 execute register1 = register1 +1
register1 =
%3D
%3D
register2 =
%3D
S2: Thread 2 execute register2 counter
register2 =
%3D
S3: Thread 2 execute register2 register2- 1
%3D
S4: Thread 1 execute counter = register1
counter =
counter=
%3D
S5: Thread 2 execute counter = register2
%3D
Transcribed Image Text:Question 6 What are the possible count outcomes of this pseudo-code: Given count3D6 Thread_1(...) { // do something Thread_2(...) { // do something count++; count--; } Just put the correct values in the value column for each step to indicate how you get each count value if each of count++ and count-- can be executed in the following steps. Step Storage Value SO: Thread 1 execute register1 = counter register1 = %3D %D S1: Thread 1 execute register1 = register1 +1 register1 = %3D %3D register2 = %3D S2: Thread 2 execute register2 counter register2 = %3D S3: Thread 2 execute register2 register2- 1 %3D S4: Thread 1 execute counter = register1 counter = counter= %3D S5: Thread 2 execute counter = register2 %3D
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Avoiding deadlock
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr