Processes and Interaction
Processes and Interaction
Processes and
Interactions
• 2.4 Semaphores
– Semaphore Operations and Data
– Mutual Exclusion
– Producer/Consumer Situations
• 2.5 Event Synchronization
• Hardware-independent solutions
– processes cooperate and compete correctly,
regardless of the number of CPUs
• Structuring mechanism
– tasks are isolated with well-defined interfaces
Figure 2-1
Fundamentals of Modern Operating Systems 8
Structuring Process Flow
• Compare:
We have seen expression
for (c) using S/P,
(d) cannot be expressed
using S/P
– it is not properly nested
Figure 2-4
p1: R1 = x; p2: …
R1 = R1+1; R2 = x;
x = R1 ; R2 = R2+1;
… x = R2;
• x has only been incremented once
• The first update (x=R1) is lost
• Problem statement:
cobegin
p1: while(1) {CS1; program1;}
//
p2: while(1) {CS2; program2;}
//
...
//
pn: while(1) {CSn; programn;}
coend
Figure 2-5
• UNIX signals
• kill(pid, sig)
send signal
(SIGHUP, SIGILL, SIGKILL, …)
• process may ignore signal
• process may catch signal