Professional Documents
Culture Documents
Chapter 3: 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 describe communication in clientserver systems
Process
Program in execution
Dynamic/active entity
Limited life span
Process Concept
An operating system executes a variety of
programs:
interchangeably
Process a program in execution; process
execution must progress in sequential fashion
A process includes:
program counter
stack
data section
Process Creation
System initialization
System starts , when os booted
Execution of a process creation system
call
System call to create a new process
UNIX fork
windows - Createprocess
Process Termination
Normal Exit
Error Exit
Fatal Error
Killed by another process
Process State
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 to be
assigned to a processor
terminated: The process has finished
execution
Process Scheduling
What is Scheduling ?
Processor management is concerned with the
Process Scheduling
Switches from running to waiting state.
Switches from running to ready state.
Switches from waiting to ready.
Terminates.
Scheduling under 1 and 4 is non-pre-emptive. All
other scheduling are pre-emptive.
1) Preemptive
2) Non-Preemptive
Process Scheduling
Non-preemptive
Executes only when:Process is terminated
Process switches from running to blocked
Simple to implement but unsuitable for time-sharing
systems
Preemptive
Executes at times above, also when:Process is created
Blocked process becomes ready
A timer interrupt occurs
More overhead, but keeps long processes from
monopolizing CPU
Must not pre-empt OS kernel while its servicing a system
call (e.g., reading a file) otherwise OS may end up in an
inconsistent state
Process Scheduling
Job queue set of all processes in the system
Queues
Ready queue set of all processes residing in
Process Scheduling
Queue is represented by rectangular box.
The circles represent the resources that serve
the queues.
The arrows indicate the process flow in the
system.
Queues are of two types
Ready queue
Device queue
Process Scheduling
Types of Process Scheduling:
1)Short Term Scheduling:
Short term scheduling is concerned with the allocation
Schedulers
Schedulers (Cont)
Short-term scheduler is invoked very frequently
Context Switch
When CPU switches to another process, the
Dispatcher
OS module which transfers control of CPU
Process Scheduling
Scheduling Criteria:
CPU Utilization
Keep
Process Scheduling
Scheduling Criteria:
Response Time (in a time-sharing environment)
amount
Process Creation
Parent process create children processes, which,
Execution
Parent and children execute concurrently
Parent waits until children terminate
Process Termination
system
processes (abort)
Interprocess
Processes within a system may be independent
Communication
or cooperating
Cooperating process can affect or be affected by
communication (IPC)
Two models of IPC
Shared memory
Message passing
Cooperating Processes
Independent process cannot affect or be
Producer-Consumer
Paradigm for cooperating processes,
Problem
producer process produces
information that is consumed by a
consumer process
unbounded-buffer places no practical
Direct Communication
Processes must name each other explicitly:
send (P, message) send a message to process P
receive(Q, message) receive a message from
process Q
Properties of communication link
Links are established automatically
A link is associated with exactly one pair of
communicating processes
Between each pair there exists exactly one link
The link may be unidirectional, but is usually bidirectional
Indirect Communication
Messages are directed and received from mailboxes
Indirect Communication
Operations
create a new mailbox
send and receive messages through mailbox
destroy a mailbox
Indirect Communication
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.
Synchronization
Message passing may be either blocking or
non-blocking
Blocking is considered synchronous
message is received
Blocking receive has the receiver block until
a message is available
(LPC) facility
Only works between processes on the same system
Uses ports (like mailboxes) to establish and maintain
communication channels
Communication works as follows:
Sockets
Remote Procedure Calls
Pipes
Remote Method Invocation (Java)
Sockets
communication
Concatenation of IP address and port
The socket 161.25.19.8:1625 refers
to port 1625 on host 161.25.19.8
Communication consists between a
pair of sockets