Concurency Consider the following program: const int n = 7; int tally; void tota
ID: 3826570 • Letter: C
Question
Concurency Consider the following program: const int n = 7; int tally; void total() { int count; for (count = 1; count <= n; count++) { tally++; } } void main() { tally = 0; parbegin (total( ),total( )); write(tally); } # Run 2 copies of process total concurrently(a) Determine the proper lower 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. Explain your answer.
(b) Suppose that an arbitrary number (i.e., instead of only two) of these processes total 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? Explain your answer. Concurency Consider the following program: const int n = 7; int tally; void total() { int count; for (count = 1; count <= n; count++) { tally++; } } void main() { tally = 0; parbegin (total( ),total( )); write(tally); } # Run 2 copies of process total concurrently
(a) Determine the proper lower 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. Explain your answer.
(b) Suppose that an arbitrary number (i.e., instead of only two) of these processes total 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? Explain your answer. Concurency Consider the following program: const int n = 7; int tally; void total() { int count; for (count = 1; count <= n; count++) { tally++; } } void main() { tally = 0; parbegin (total( ),total( )); write(tally); } # Run 2 copies of process total concurrently
(a) Determine the proper lower 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. Explain your answer.
(b) Suppose that an arbitrary number (i.e., instead of only two) of these processes total 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? Explain your answer.
Explanation / Answer
#include <iostream>
#include <string>
const int n = 20;
int tally;
void total() {
int count;
for (count = 1; count <= n; count++){
tally++;
}
}
void main() {
tally = 0;
parbegin (total (), total ());
write (tally);
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.