





















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















































A B C
Multiprogramming A B C A B C B
A B C
Multiprocessing
Bounded-Buffer
while (true) {
/* produce an item and put in nextProduced */
while (count == BUFFER_SIZE); // do nothing
/* add one item */
buffer [in] = nextProduced;
in = (in + 1) % BUFFER_SIZE;
count++;
}
register1 = count register1 = register1 + 1 count = register
register2 = count registe2 = register2 - 1 count = register
count++; count--; must be performed atomically.
Solution to Critical-Section Problem
Assume that each process executes at a nonzero speed No assumption concerning relative speed of the N processes
do { while (turn != i) ; critical section turn = j ; remainder section } while (1) ;
do { flag[i] = true; while (flag[j]) ; critical section flag [i] = false; remainder section } while (1);
code
instructions
lock.Acquire();
Critical section
lock.Release();