Chapter 2 Process
Chapter 2 Process
Chapter 2 Process
PROCESS MANAGEMENT
CHAPTER 2: PROCESSES
Process Concept
Process Scheduling
Operations on Processes
Interprocess Communication
Examples of IPC Systems
Communication in Client-Server Systems
OBJECTIVES
To introduce the notion of a process -- a program in execution,
which forms the basis of all computation
To describe the various features of processes, including
scheduling, creation and termination, and communication
To explore interprocess communication using shared memory
and message passing
To describe communication in client-server systems
PROCESS CONCEPT
An operating system executes a variety of programs:
Batch system – jobs
Time-shared systems – user programs or tasks
Execution options
Parent and children execute concurrently
Parent waits until children terminate
A TREE OF PROCESSES IN LINUX
PROCESS CREATION (CONT.)
Address space
Child duplicate of parent
Child has a program loaded into it
UNIX examples
fork() system call creates new process
exec() system call used after a fork() to replace the process’ memory space
with a new program
PROCESS TERMINATION
Process executes last statement and then asks the
operating system to delete it using the exit()
system call.
Returns status data from child to parent (via wait())
Process’ resources are deallocated by operating system
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;
Implementation issues:
How are links established?
Can a link be associated with more than two processes?
How many links can there be between every pair of communicating
processes?
What is the capacity of a link?
Is the size of a message that the link can accommodate fixed or variable?
Is a link unidirectional or bi-directional?
MESSAGE PASSING (CONT.)
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.
SYNCHRONIZATION
Message passing may be either blocking or non-
blocking
Blocking is considered synchronous
Blocking send -- the sender is blocked until the message is received
Blocking receive -- the receiver is blocked until a message is
available
message next_produced;
while (true) {
/* produce an item in next produced */
send(next_produced);
}
message next_consumed;
while (true) {
receive(next_consumed);