1. List four design issues for which the concept of concurrency is relevant.
2. What is the basic requirement for the execution of concurrent processes?
1. Consider a concurrent program with two processes, p and q, defines as follows. A, B, C, D and E are arbitrary atomic ( indivisible ) statements. Assume that the main program ( not shown ) does a parbegin of the two processes.
Void p() Void q()
Show all the possible interleavings of the execution of preceding two processes (Show this by giving execution “traces” in terms of the atomic statements)
2. Consider the following program:
const int n = 50;
for ( count = 1; count 0)
place this process in s.queue;
if (there is at least one process blocked on semaphore s)
remove a process P from s.queue;
place process P on ready list;
Compare this set of definitions with that of Figure 5.3. Note one difference: With the preceding definition, a semaphore can never take on a negative value. Is there any difference in the effect of these two sets of definitions when used in programs? That is, could you substitute one set for the other without altering the meaning of the program?
5. (5.3) Given the following code:
x=1; (* statement 1 *)
y=y+x; (* statement 2 *)
begin (* main program *)
That is, suppose a process has two concurrent threads; one thread executes statements 1 and 2, and the other thread executes statements 3 and 4. List all the possible values of the variables when the code finishes executing - include the order the statements (1-4) must execute for each ending value.... [continues]
Cite This Essay
(2011, 05). If Two Heads Are Better Than One, Are Four Even Better?. StudyMode.com. Retrieved 05, 2011, from http://www.studymode.com/essays/If-Two-Heads-Are-Better-Than-688773.html
"If Two Heads Are Better Than One, Are Four Even Better?" StudyMode.com. 05 2011. 05 2011 <http://www.studymode.com/essays/If-Two-Heads-Are-Better-Than-688773.html>.
"If Two Heads Are Better Than One, Are Four Even Better?." StudyMode.com. 05, 2011. Accessed 05, 2011. http://www.studymode.com/essays/If-Two-Heads-Are-Better-Than-688773.html.