OS CH3
OS CH3
● Maximize CPU use, quickly switch processes onto CPU for time
sharing
5 4
wai
⚫ 1 = some predefined policy
ting
CPU
P1 sche P2
duler
Inter
Runn rupt Save state P1 Read
ing y
Select P2
Restore state
P2
Read Runn
y ing
Inter
rupt
Save state P2
Select P1
Restore state
Runn Read
P1
ing y
● Execution options
● Parent and children execute concurrently (e.g., Web Server)
● Parent waits until children terminate (e.g., Batch Processing)
● 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
● Some OS’s do not allow child to exists if its parent has terminated. If
a process terminates, then all its children must also be terminated.
● Cascading termination: All children, grandchildren, etc. are
terminated.
● The termination is initiated by the OS
● 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?
● Physical:
4 Shared memory
4 Hardware bus
4 Network
● Logical:
4 Direct or indirect
4 Synchronous or asynchronous
4 Automatic or explicit buffering
● 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.
● Sockets
● Remote Procedure Calls (RPC)
● Pipes
● All ports below 1024 are well known, used for standard services
● The client-side stub locates the server and marshalls the parameters
● Issues:
● Is communication unidirectional or bidirectional?
● In the case of two-way communication, is it half or full-duplex?
● Must there exist a relationship (i.e., parent-child) between the
communicating processes?
● Can the pipes be used over a network?
$ ls | grep “examples”
$ mkfifo named_pipe_example
$ cat named_pipe_example