Suppose that two di?erent processes are sharing a variable tally which is initia
ID: 3533605 • Letter: S
Question
Suppose that two di?erent processes are sharing a variable tally which is initialized to zero. Both processes are executing a loop shown below (and do nothing else). Even though they are using shared variables, in the following code no special precautions are taken to avoid race conditions.
int i; // i is not a shared variable
for (i=1; i<=50; i="" p="">
tally = tally + 1;
Determine as to which numbers could potentially be the final value of the shared variable tally after both the processes are completely done. Assume that processes can execute at any relative speed and can be interrupted at times over which we dont have control. Also, assume that a variable can be incremented only after it has been loaded into a general purpose register by a separate machine instruction.
Explanation / Answer
Value would potentially be any value from 50 to 100, because
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.