You are on page 1of 11

System Software

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..

• Two processes may be associated with the same


program.

E.g. Several users running the different copies of


mail program.

Each of these are separate processes although the text sections


are equivalent, because data section vary.

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

admitted interrupt exit

Ready Running

scheduler
dispatch

I/O or event I/O or event


completion wait

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.

• PCB serves as the repository for any information


that may vary from process to process.

6
How CPU switch from process to process

7
Process Scheduling
• Essential part of a multiprogramming operating
system.

• Such operating systems allow more than one


process to be loaded into the executable memory
at a time and loaded process shares the CPU
using time multiplexing.

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.

• Long-term schedulers determines which jobs are


admitted.

• Medium-term scheduler determines which process


to swap in/out of disk to/from memory.

11

You might also like