L5 - Process Management1111
L5 - Process Management1111
MANAGEMENT
Dr. Sukanta Ghosh
Systems and Architecture
PROCESS
CONCEPT
An operating system executes a variety of
programs:
Batch system – jobs
Time-shared systems – user programs or
tasks
The terms job and process almost
interchangeably.
Process – a program in execution; process
execution must progress in sequential
fashion
A process includes:
program counter
stack
data section
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 process
terminated: The process has finished execution
DIAGRAM OF PROCESS
STATE
OPERATIONS ON THE
PROCESS
Creation: Once the process is created, it will be ready and come into the
ready queue (main memory) and will be ready for the execution.
Scheduling: Selecting the process which is to be executed next, is known
as scheduling.
Execution: Once the process is scheduled for the execution, the processor
starts executing it.
Deletion/killing: Once the purpose of the process gets over then the OS
will kill the process. The Context of the process (PCB) will be deleted and
the process gets terminated by the Operating system.
PROCESS CONTROL
BLOCK (PCB)
Information associated with each process
Process state
Program counter
CPU registers
CPU scheduling information
Memory-management information
Accounting information
I/O status information
CPU SWITCH
FROM PROCESS
TO PROCESS
CONTEXT SWITCH
When CPU switches to another process, the system must save the state of
the old process and load the saved state for the new process
Context-switch time is overhead; the system does no useful work while
switching
Time dependent on hardware support
PROCESS
SCHEDULING
QUEUES
The PCB related to the
process is also stored in
the queue of the same
state.
If the Process is moved
from one state to another
state then its PCB is also
unlinked from the
corresponding queue and
added to the other state
queue in which the
transition is made.
PROCESS SCHEDULING
QUEUES
Job Queue
In starting, all the processes get stored in the job queue.
It is maintained in the secondary memory.
The long-term scheduler picks some of the jobs and put them in the primary memory.
Ready Queue
Ready queue is maintained in primary memory.
The short-term scheduler picks the job from the ready queue and dispatch to the CPU
for the execution.
Waiting Queue
When the process needs some IO operation in order to complete its execution, OS
changes the state of the process from running to waiting.
The context (PCB) associated with the process gets stored on the waiting queue
which will be used by the Processor when the process finishes the IO.
REPRESENTATION OF
PROCESS SCHEDULING
SCHEDULERS
Long-term scheduler (or job scheduler)
Selects which processes should be brought into the ready queue.
Controls the degree of Multiprogramming.
Purpose is to choose a perfect mix of IO bound and CPU bound processes.
Long-term scheduler is invoked very infrequently (seconds, minutes) => (may be
slow)
Execution
Parent and children execute concurrently
Parent waits until children terminate
PROCESS CREATION
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
A TREE OF
PROCESSES
ON A TYPICAL
SOLARIS
PROCESS TERMINATION
Process executes last statement and asks the operating system to delete it
(exit)
Output data from child to parent (via wait)
Process’ resources are deallocated by operating system
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.
CLIENT-SERVER
COMMUNICATION
Sockets
Remote Procedure Calls
Remote Method Invocation (Java)
SOCKETS
A socket is defined as an
endpoint for
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
REMOTE PROCEDURE CALLS
Remote procedure call (RPC) abstracts procedure calls between processes
on networked systems.
Stubs – client-side proxy for the actual procedure on the server.
The client-side stub locates the server and marshalls the parameters.
The server-side stub receives this message, unpacks the marshalled
parameters, and peforms the procedure on the server.
REMOTE METHOD
INVOCATION
Remote Method Invocation (RMI) is a Java mechanism similar to RPCs.
RMI allows a Java program on one machine to invoke a method on a remote
object.
THANK YOU