Chapter 3: Processes��https://classroom.google.com/c/Nzk1NzAxMzkyMTIy?cjc=2lo4evz7
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Concept
3.2
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Concept (Cont.)
3.3
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process in Memory
3.4
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process State
3.5
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Diagram of Process State
3.6
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Control Block (PCB)
Information associated with each process
(also called task control block)
3.7
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
CPU Switch From Process to Process
3.8
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Scheduling
3.9
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Schedulers
3.10
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Addition of Medium Term Scheduling
3.11
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Operations on Processes
3.12
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Creation
3.13
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
A Tree of Processes in Linux
3.14
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Creation (Cont.)
3.15
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
C Program Forking Separate Process
3.16
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
3.17
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
3.18
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Termination
3.19
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Process Termination
pid = wait(&status);
3.20
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Interprocess Communication
3.21
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Communications Models
(a) Message passing. (b) shared memory.
3.22
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Producer-Consumer Problem
3.23
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Bounded-Buffer – Shared-Memory Solution
#define BUFFER_SIZE 10
typedef struct {
. . .
} item;
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
3.24
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Bounded-Buffer – Producer
item next_produced;
while (true) {
/* produce an item in next produced */
while (((in + 1) % BUFFER_SIZE) == out)
; /* do nothing */
buffer[in] = next_produced;
in = (in + 1) % BUFFER_SIZE;
}
3.25
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Bounded Buffer – Consumer
item next_consumed;
while (true) {� while (in == out)
; /* do nothing */� next_consumed = buffer[out];
out = (out + 1) % BUFFER_SIZE;�
/* consume the item in next consumed */
}
3.26
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Interprocess Communication – Shared Memory
3.27
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Interprocess Communication – Message Passing
3.28
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Direct Communication
3.29
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Indirect Communication
3.30
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Indirect Communication
send(A, message) – send a message to mailbox A
receive(A, message) – receive a message from mailbox A
3.31
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
Indirect Communication
3.32
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition
End of Chapter 3
Silberschatz, Galvin and Gagne ©2013
Operating System Concepts – 9th Edition