Professional Documents
Culture Documents
Lecture 2
Process Management
Process
• Process is a program in execution.
• Not only the program code.
• Process includes:
– Program code (text section)
– Program counter (specify the next instruction to execute)
– Contents of registers (accumulators, stack pointers etc.)
– Process stack (temporary data. E.g. method parameters,
local variables, return addresses)
– Data section (E.g. global variables)
2
Process contd..
3
Process States
• As a process executes, it changes state.
• State: current activity of that process.
• Each process may be in one of the following states.
– New : The process is being created.
– Running : Instructions are being executed.
– Waiting : The process is waiting for some event to occur.
(Such as I/O completion)
– Ready : The process is waiting to be assigned to a
processor.
– Terminated: The process has finished execution.
4
Process States
New Terminate
Ready Running
scheduler
dispatch
Waiting
5
Process Control Block (PCB)
• Each process is represented in OS by a PCB.
• Contains information associated with a specific
process.
– Process no, program counter, registers, memory limits,
list of opened files, process state etc.
6
How CPU switch from process to process
7
Process Scheduling
• Essential part of a multiprogramming operating
system.
8
Queuing diagram of process scheduling
9
Schedulers
• A process migrates between various scheduling
queues.
– Selection on which process to migrate is done by the
appropriate scheduler.
• Long-term scheduler (or job scheduler) selects
which processes should be brought into the ready
queue.
– It is invoked very infrequently (seconds, minutes) the
scheduler can be slow.
– It controls the degree of multiprogramming.
– A time sharing system often have no long-term
scheduler.
10
Schedulers
• Short-term scheduler (or CPU scheduler) selects
one of the processes in memory ready for
execution, and allocates the CPU to it.
– It is invoked very frequently (milliseconds) the scheduler must be
fast.
11