Operating Systems - Ch3 - Mod - Reem
Operating Systems - Ch3 - Mod - Reem
Operating Systems - Ch3 - Mod - Reem
Operating System Concepts, Avi Silberschatz, Peter Baer Galvin, Greg Gagne,
John Wiley & Sons, ISBN 978-1-118-06333-0 , 9th Ed., 2012.
Processes
Process Concept
Process Scheduling
Operations on Processes
Interprocess Communication
Examples of IPC Systems
Stack containing
temporary data
Function parameters,
return addresses, 0
local variables
Process in Memory
Heap containing
memory dynamically
allocated during run
time
4 Operating System Dr. Reem Ibrahim
Process Concept
As a process executes, it
changes state
new: The process is being
created
running: Instructions are
being executed
waiting: The process is
waiting for some event to
occur
ready: The process is waiting Diagram of Process State
to be assigned to a processor
terminated: The process has
finished execution
5 Operating System Dr. Reem Ibrahim
Process Concept
Process Control Block (PCB)
Each process is represented in the operating system by a
PCB—also called a task control block.
It contains many pieces of information associated with a
specific process, including these:
Process state – running, waiting, etc
Program counter – location of instruction to next
execute
CPU registers – contents of all process-centric registers
CPU scheduling information- priorities, scheduling
queue pointers
Memory-management information – memory
allocated to the process
Accounting information – CPU used, clock time
elapsed since start, time limits
I/O status information – I/O devices allocated to
process, list of open files
Execution options
Parent and children execute concurrently bash khelper pdflush sshd
pid = 8416 pid = 6 pid = 200 pid = 3610
Parent waits until children terminate
A tree of processes
emacs
on a typical Linux tcsch
ps
pid = 9298 pid = 9204 system pid = 4005
Bounded-Buffer –
Shared-Memory Solution
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.
24 Operating System Dr. Reem Ibrahim
Interprocess Communication
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
Non-blocking is considered asynchronous
Non-blocking send -- the sender sends the message and continue
Non-blocking receive -- the receiver receives:
A valid message, or
Null message
Producer-consumer Problem