Question: Consider the following program: const int n = 50; int tally; void total() { int count; for (count = 1; count
Consider the following program:
const int n = 50;
int tally;
void total()
{
int count;
for (count = 1; count<= n; count++){
tally++;
}
}
void main()
{
tally = 0;
parbegin (total (), total ());
write (tally);
}
a. Determine the proper lower bound and upper bound on the final value of the shared variable tally output by this concurrent program. Assume processes can execute at any relative speed and that a value can only be incremented after it has been loaded into a register by a separate machine instruction.
b. Suppose that an arbitrary number of these processes are permitted to execute in parallel under the assumptions of part (a). What effect will this modification have on the range of final values of tally?
Step by Step Solution
3.37 Rating (169 Votes )
There are 3 Steps involved in it
a On casual inspection it appears that tally will fall in the range 50 tally 100 since from 0 to 50 increments could go unrecorded due to the lack of ... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
451-C-S-D-B-O-S (66).docx
120 KBs Word File
