Change
Cambio processo
Preempt_1
Rischedula processo + chiama change
Preempt_2
ReturnSleep_on_1
Porta processo in attesa
Sleep_on_2
Risveglio
Wake_up
Riporta processo in stato pronto
R_int (CK)_1
Controllo tempo residuo, rischedulo -> passo al “pronto”
R_int (CK)_2
Ritorno.
R_int (E)_1
Wake_up (E)
R_int (E)_2
Preempt
R_int (E)_3
Ritorno
G_SVC_1
Case “Fork”: {…}
Case “Exit”: {…}
End Case
G_SVC_2
Preempt
G_SVC_3
Return
Server
Main () {
Listen () While ( 1 ) {
Accept () Pid = Fork () If (Pid ==0) {
Execl() Write () Exit ( 1 ) } Else
Close ( ) }
}
Client
Connect () Sleep ( 2 ) Send ( ) Write ( ) P -> Server
S > R > Q > P > IDLE R,S -> Client
G -> Server Offspring
Evento Info Moduli S.o. Contesto Stato Processi
P Q R S
R connect G_SVC_1 R Exec N.E. Wait (e1) N.E.
connect R
Sleep_on (E1)_1 R Change R->P
Preempt_2 P
P accept G_SVC_1 P Exec N.E. Ready N.E.
Accept P
Wake_up (E1) P
Accept P
G_SVC_2 P
G_SVC_3 P
P codice utente Nessuno P Exec N.E. Ready N.E.
P fork () G_SVC_1 P Ready Ready Exec U
FORK P
G_SVC_2 P
Preempt_1 P
Change P->R Sleep_on (E1)_2 R
Connect R
G_SVC_2/3 R
R Sleep ( 2 ) G_SVC_1 R Ready Ready Exec U N.E.
Sleep R
Sleep_on (E2)_1 R Change R->Q
G_SVC_2/3 Q
Q Execl G_SVC_1 Q Ready Ready Exec N.E.
Execl Q
G_SVC_2/3 Q
Q Read G_SVC_1 Q Exec Wait (E1) Wait (E2) N.E.
READ Q
Sleep_on(E3) Q Change Q->P
Preempt_2 P
G_SVC_2/3 P
P Accept G_SVC_1 P Wait (E4) Wait (E3) Wait (E2) N.E.
Accept P
Sleep_on(E4)_1 P Change P->IDLE G_SVC_2/3 IDLE
S Connect G_SVC_1 S Ready Wait (E3) Wait (E2) Exec
Connect S
Wake_up(E4) S
Connect S
G_SVC_2 S
S Connect:
Interrupt
R_INT(CK)_1 S Ready Wait (E3) Ready Exec
Wake_up(E2) S
R_INT(CK)_2 S
Main () {
Pid 1= Fork () If (Pid 1 = = 0)
{
… Exit (1)
… } Else {
Write () Pid 2 = Fork ()
If (Pid 2 = = 0) { Write (); Exit () ; } Pid 2 = Waitpid(Pid 1);
Exit (0) }
Evento P Q R
P FORK Exec Ready N.E.
P WRITE Wait (E1) Exec N.E.
Q USER Wait (E1) Exec N.E.
Q FINE QUANTO Wait (E1) Exec N.E.
Q FINE WRITE Exec Ready N.E.
P FORK Exec Ready Ready
P WAITPID Wait (E2) Ready Exec
R WRITE Wait (E2) Exec Wait (E3)
Q EXIT Wait (E2) N.E. Wait (E3)