Module 4: Processes: Operating System Concepts
Module 4: Processes: Operating System Concepts
Module 4: Processes: Operating System Concepts
Process Concept
Process Scheduling
Operation on Processes
Cooperating Processes
Interprocess Communication
4.1
Process Concept
A process includes:
program counter
stack
data section
4.2
Process State
4.3
4.4
Process state
Program counter
CPU registers
CPU scheduling information
Memory-management information
Accounting information
I/O status information
4.5
4.6
4.7
4.8
4.9
4.10
Schedulers
4.11
4.12
Schedulers (Cont.)
4.13
Context Switch
4.14
Process Creation
Resource sharing
Parent and children share all resources.
Children share subset of parents resources.
Parent and child share no resources.
Execution
Parent and children execute concurrently.
Parent waits until children terminate.
4.15
Address space
Child duplicate of parent.
Child has a program loaded into it.
UNIX examples
fork system call creates new process
execve system call used after a fork to replace the process
memory space with a new program.
4.16
4.17
Process Termination
4.18
Cooperating Processes
4.19
Producer-Consumer Problem
4.20
Shared data
var n;
type item = ;
var buffer. array [0..n1] of item;
in, out: 0..n1;
Producer process
repeat
4.21
Bounded-Buffer (Cont.)
Consumer process
repeat
while in = out do no-op;
nextc := buffer [out];
out := out+1 mod n;
until false;
4.22
Threads
4.23
Threads (Cont.)
4.24
4.25
4.26
Solaris 2 Threads
4.27
4.28
Implementation Questions
4.29
Direct Communication
4.30
Indirect Communication
Operations
create a new mailbox
send and receive messages through mailbox
destroy a mailbox
4.31
Mailbox sharing
P1, P2, and P3 share mailbox A.
P1, sends; P2 and P3 receive.
Who gets the message?
Solutions
Allow a link to be associated with at most two processes.
Allow only one process at a time to execute a receive
operation.
Allow the system to select arbitrarily the receiver. Sender is
notified who the receiver was.
4.32
Buffering
4.33
Process terminates
Lost messages
Scrambled Messages
4.34