Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following C-like pseudocode program: const int n = 50; int total; // shared variable void sum() { for ( int count = 1;

Consider the following C-like pseudocode program:

const int n = 50;

int total; // shared variable

void sum()

{

for (int count = 1; count <= n; count++)

{

total++;

}

}

void main()

{

total = 0;

// create two concurrent instances of procedure sum

parbegin(sum(), sum());

write (total);

}

Note: The pseudocode statement parbegin creates concurrent processes that run the procedure code indicated by the arguments of parbegin.

a)Determine the actual lower bound and upper bound on the final value of the shared variable total output by this concurrent program. Assume that the two processes created by parbegin 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 N of these processes are permitted to execute concurrently under the assumptions of part (a). What effect will this modification have on the range of final values of total?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

=+Where does the focus of labor relations lie? Is it collective

Answered: 1 week ago

Question

=+With whom does the firm have to negotiate?

Answered: 1 week ago