Sunteți pe pagina 1din 16

Process and CPU Scheduling

Part - I
Introduction
An Operating system executes a variety of programs

Batch system executes jobs.

Real Time systems has user programs or tasks.

Ex: Windows may need to run several programs like


word processor, web browser and so on.

We can say these as processes.


Process Concept
Let us put a Question. What is a Process?
Process Concept

Process a program in execution.

Process execution must progress in sequential


fashion.

Job and Process almost interchangeably used.

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
Process State diagram
Process Control Block (PCB)
Each process is represented in the OS by a
Process Control Block (PCB).
Also called as Task Control Block.
It contains many pieces of information associated
with a specific process.
Process state
Program counter: It indicates the address of the next
instruction
CPU registers: it allow to process correctly if an
interrupt occurs
Process Control Block (PCB)
CPU scheduling information: includes process
priority, scheduling parameters.
Memory -management information: Base and
limit registers, the page tables
Accounting information: consists amount of CPU
and real time used, time limits, job or process
numbers.
I/O status information: includes the list of I/O
process allocated to the process, list of open
files
Process Control Block (PCB)
Threads
The process model discussed so far as implied
that a process is program that performs a single
thread of execution.
Word-processor program, a single thread of
instruction is being executed.
Single thread can perform process only one task
at a one time.
Modern operating systems allows process to have
multiple threads of execution.
It performs more than one task at a time.
CPU Switch From Process to Process
?
The day before yesterday, Chris was 7 years
old. Next year, she'll turn 10. How is this
possible?
?
The day before yesterday, Chris was 7 years
old. Next year, she'll turn 10. How is this
possible?
Process Scheduling
The objective of multiprogramming is to have
some process running at all times, to
maximize CPU utilization.
The objective of time sharing is to switch the
CPU among processes so frequently.
To meet these objectives, the process
scheduler selects an available process for
program execution on the CPU.
Process Scheduling Queues
Job queue set of all processes in the system.
Ready queue set of all processes residing in
main memory, ready and waiting to execute. It is
stored in linked lists. This queue header contains
pointers of first and last PCBs in the list.
Device queues set of processes waiting for an
I/O device. Each device has its own device queue.

Note:- Process migrate between the various queues.


Ready Queue And Various I/O Device
Queues