0% found this document useful (0 votes)
8 views40 pages

L5 - Process Management1111

it explain about process management

Uploaded by

Prince Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views40 pages

L5 - Process Management1111

it explain about process management

Uploaded by

Prince Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

PROCESS

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)

 Short-term scheduler (or CPU scheduler)


 Selects which process should be executed next and allocates CPU.
 If it selects job whose CPU burst time is very high then all the jobs after that, will
have to wait in the ready queue for a very long time. (Starvation ).
 Short-term scheduler is invoked very frequently (milliseconds) => (must be fast)
ADDITION OF MEDIUM-TERM
SCHEDULING

 It removes the process (I/O


Request) from the running state
to make room for the other
processes.
 It reduces the degree of
multiprogramming.
TYPES OF PROCESSES
 Processes can be described as either:

 I/O-bound process – spends more time doing I/O than computations,


many short CPU bursts

 CPU-bound process – spends more time doing computations; few very


long CPU bursts
TIMES RELATED TO THE
PROCESS
 Arrival Time: The time at which the process enters into the ready queue is
called the arrival time.
 Burst Time: The total amount of time required by the CPU to execute the whole
process is called the Burst Time.
 Completion Time: The Time at which the process enters into the completion
state or the time at which the process completes its execution, is called
completion time.
 Turnaround Time: The total amount of time spent by the process from its
arrival to its completion, is called Turnaround time.
 Waiting Time: The Total amount of time for which the process waits for the CPU
to be assigned is called waiting time.
 Response Time: The difference between the arrival time and the time at which
the process first gets the CPU is called Response Time.
TIMES RELATED TO THE
PROCESS
PROCESS CREATION
 Parent process create children processes, which, in turn create other
processes, forming a tree of processes
 Resource sharing
 Parent and children share all resources
 Children share subset of parent’s resources
 Parent and child share no resources

 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

 Parent may terminate execution of children processes (abort)


 Child has exceeded allocated resources
 Task assigned to child is no longer required
 If parent is exiting
 Some operating system do not allow child to continue if its parent terminates
 All children terminated - cascading termination
COOPERATING PROCESSES
 Independent process cannot affect or be affected by the execution of
another process
 Cooperating process can affect or be affected by the execution of another
process
 Advantages of process cooperation
 Information sharing
 Computation speed-up
 Modularity
 Convenience
PRODUCER-CONSUMER
PROBLEM
 Paradigm for cooperating processes, producer process produces
information that is consumed by a consumer process
 unbounded-buffer places no practical limit on the size of the buffer
 bounded-buffer assumes that there is a fixed buffer size
INTERPROCESS
COMMUNICATION (IPC)
 Inter-process communication is used for exchanging useful information between
numerous threads in one or more processes (or programs).
 Message system – processes communicate with each other without resorting to
shared variables
 IPC facility provides two operations:
 send(message) – message size fixed or variable
 receive(message)

 If P and Q wish to communicate, they need to:


 establish a communication link between them
 exchange messages via send/receive

 Implementation of communication link


 physical (e.g., shared memory, hardware bus)
 logical (e.g., logical properties)
IMPLEMENTATION
QUESTIONS
 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?
IMPLEMENTATION
QUESTIONS
 How are links established?
 Links in IPC are typically established through direct or indirect
communication methods:
 Direct communication: A process explicitly identifies the recipient of
its message. The communication link is established when two processes
reference each other by process IDs.
 Indirect communication: Processes communicate via a shared
intermediary (such as a mailbox or a message queue), and the link is
established between processes and the shared mailbox.
IMPLEMENTATION
QUESTIONS
 Can a link be associated with more than two processes?
 Yes, a link can be associated with more than two processes, especially in
indirect communication models where multiple processes can send or
receive messages from a shared mailbox.
 However, in direct communication, the link is typically between exactly two
processes (the sender and the receiver).
IMPLEMENTATION
QUESTIONS
 How many links can there be between every pair of
communicating processes?
 There is usually one link per pair of communicating processes in direct
communication.
 However, in indirect communication, multiple processes can communicate
through a common mailbox, leading to multiple communication pathways
through the shared mailbox.
 Thus, the number of links between any pair can vary depending on the
system’s messaging structure.
IMPLEMENTATION
QUESTIONS
 What is the capacity of a link?
 The capacity of a link refers to the maximum number of messages that can
be stored in the link (buffer) at any time:
 In some systems, the link has finite capacity, meaning that the link can
hold a limited number of messages, and sending may be blocked if the
buffer is full.
 In other systems, the link may have infinite capacity, where any number
of messages can be stored without blocking the sender.
IMPLEMENTATION
QUESTIONS
 Is the size of a message that the link can accommodate fixed or
variable?
 The message size can be either fixed or variable, depending on the
implementation of the IPC system.
 Some systems define a fixed message size for simplicity and efficiency,
while others allow variable-sized messages to accommodate different
communication needs.
IMPLEMENTATION
QUESTIONS
 Is a link unidirectional or bi-directional?
 A communication link can be either unidirectional or bi-directional:
 Unidirectional: Messages can only flow in one direction (from sender to
receiver).
 Bi-directional: Messages can flow in both directions between the
processes. This allows both processes to act as senders and receivers.
COMMUNICATIONS MODELS
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 bi-directional
INDIRECT COMMUNICATION
 Messages are directed and received from mailboxes (also referred to as
ports)
 Each mailbox has a unique id
 Processes can communicate only if they share a mailbox

 Properties of communication link


 Link established only if processes share a common mailbox
 A link may be associated with many processes
 Each pair of processes may share several communication links
 Link may be unidirectional or bi-directional
INDIRECT COMMUNICATION
 Operations
 create a new mailbox
 send and receive messages through mailbox
 destroy a mailbox

 Primitives are defined as:


 send(A, message) – send a message to mailbox A
 receive(A, message) – receive a message from mailbox A
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.
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

You might also like