
























































































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!

























































































Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors
item nextProduced;
while (1) { while (((in + 1) % BUFFER_SIZE) == out);/* do nothing */ buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; }
#define BUFFER_SIZE 10 typedef struct {
... } item; item buffer[BUFFER_SIZE]; int in = 0; int out = 0; int counter = 0;
Producer process
item nextProduced; while (1) { while (counter == BUFFER_SIZE); //spin buffer[in] = nextProduced; in = (in + 1) % BUFFER_SIZE; counter++; }
register1 = counter register1 = register1 + 1 counter = register
General structure of process Pi (other process Pj) do { entry section critical section exit section remainder section } while (1);
Mutual Exclusion
no other processes can be executing in their critical sections.
Progress
a) if no process is executing in its critical section and b) there exist some processes that wish to enter their critical section
only those processes that are not executing in the remainder section can participate in the decision on which will enter the critical section next.
The selection of the processes cannot be postponed indefinitely. Docsity.com