Sunteți pe pagina 1din 30

Process management

Allocates resources to processes


Enables processes to share and exchange
information
Protects the resources of each process from
other processes
Provides facilities for process sharing and
synchronization
Schedules the work done by the processor

Process
an instance of a program in execution
Program
consists of only 3 statements
can either be

I/O bound
CPU bound

Process State Transition Diagram

Figure 3.2

Process Scheduler
3 Types of schedulers
Long-term scheduler (job / admission)
Short-term scheduler (cpu)
Medium-term scheduler (Midterm)

OS Scheduler
Long-term Scheduler
Decides which of the new processes
are added to the pool of processes
ready for execution,
and determines which of the
processes is to be released or
terminated

Medium-term Scheduler

Decides which of the processes


should be partially or fully loaded,
suspended or to resume in the main
memory

Short-term Scheduler
Decides as to which of the available
processes will be allotted the
processor and for how long

Process Scheduling
CPU Scheduling
sequence or order of process
execution as they are allotted the
processor.
CPU Scheduling Algorithm
The many ways of allotting the
processor to a specific job or process

The main purposes of scheduling


algorithms are
to minimize resource starvation
to ensure fairness among the parties
utilizing the resources

Evaluation Criteria of the best


CPU scheduling algorithm

Increase CPU Utilization

Make CPU busy processing at all times

% time the processor is busy


Increase throughput

measures how much work is done in a given time


Reduce Turn-around time

amount of time to execute a particular process

Reduce Waiting time

amount of time in the ready queue before alloted cpu time

Reduce Response time

Amount of time from request until the first response

CPU Scheduling Algorithms


2 categories of CPU Scheduling algorithms
Non Preemptive algorithm
once the process is in the running state, it
will continue until the halted state.

Preemptive algorithm

currently running process may be interrupted


and moved to the ready state even if the total
burst time has not been consumed.

CPU Scheduling Evaluation

Gantt chart shows execution pattern


Turn-around Time
Waiting Time
CPU Utilization

First Come First Serve (FCFS)


Shortest
Job First algorithms
(SJF)
CPU
Scheduling
Non-Preemptive Priority (NPP)
Preemptive Priority (PP)
Shortest Remaining Time First (SRTF)
Round Robin (RR)

Problem 1
Job

Arrival Time Burst Time

Priority

J1

13

J2

J3

J4

15

J5

17

First Come First Serve

also known as first in, first out (fifo)


allocates processor based on time of arrival
very simple implementation
low overhead
waiting time depends on arrival order, exhibits
convoy effect
possible long wait for jobs that arrived later (poor
performance)

Shortest Job First

allocates processor based on the shortest cpu burst


ready queue is treated as a priority queue based on smallest
time requirement
also called shortest job next (sjn)
uses fcfs if jobs are of the same length of burst
moving shorter jobs before longer jobs improves waiting time
of short jobs more than it harms waiting time of long jobs.
optimal with regard to turn-around and waiting time
not practical, cannot predict future cpu burst time
long jobs may never be scheduled, thus starvation occurs

Priority algorithm

sometimes called highest priority first (hpf)


each job is assigned a priority where jobs are
scheduled based on the highest priority
static priority will work well for real time slice while
dynamic priority will work well for general workload.
high priority jobs will be processed first
there is a possibility that low priority jobs will starve.

Shortest Remaining Time First

also called shortest time to completion


(stcf)
allocates processor based on the
shortest remaining burst and preempting if a shorter burst is found in
the ready queue

Round Robin

allocates the processor based on a given time slice or


quantum.
treats the ready queue as a circular queue wherein
arriving jobs or jobs preempted are placed on the tail
of the queue.
simple, low overhead, work for interactive jobs
job gets fair share of cpu
shortest job finishes more quickly
poor average waiting time with similar job lengths
performance depends on length of time slice
higher overhead

Problem 2
Process
A
B
C
D
E

Arrival
Time
0
6
6
8
10

Burst
Time
4
8
3
9
6

Priority
3
2
4
1
5

Problem 4
Process
A
B
C
D
E

Arrival
Time
0
0
2
3
10

Burst
Time
15
7
4
7
10

Priority
5
4
3
2
1

Problem 5
Process
A
B
C
D
E

Arrival
Time
0
0
2
3
10

Burst
Time
15
7
4
7
10

Priority
5
4
3
2
1

Problem 6
Process
A
B
C
D
E

Arrival
Time
0
7
5
2
3

Burst
Time
10
3
8
4
9

Priority
4
1
2
1
3

Problem 7
Job

Arrival Time

Burst Time

Priority

11

18

35

15

14

13

26

11

30

MULTILEVEL QUEUE SCHEDULING ALGORITHM

MULTILEVEL QUEUE SCHEDULING ALGORITHM

A process is assigned a queue level based on memory size,


process priority or process type.
Each level has its own defined scheduling algorithm.
The order of processing in between queue levels may be
based on:

priority using either non pre-emptive or pre-emptive policy.


Lower queue levels will only be able to run when all the
higher level queues are empty.
Quantum or time slice where queue levels are given specified
time slice in the central processing unit

MULTILEVEL FEEDBACK QUEUE (MFQ)

MULTILEVEL FEEDBACK QUEUE (MFQ)

The number of queues should be defined.


Each queue has a defined scheduling algorithm
used
There must be a policy used to decide when to
move up a process
There must be a policy used to decide when to
move down a process
There must be a policy used to decide in what
queue a process will enter when it needs service.

PROBLEM 8
Q0 LOW SJF
Q1 HIGH FCFS
Arrival

Queue

Time

Level

P1

Q0

P2

Q1

P3

Q0

P4

Q1

P5

Q0

P6

Q1

Process

Burst Time

Problem 9
LEVEL 0 RR Q= 2
LEVEL 1 RR Q= 4
LEVEL 2 SJF
Process
A
B
C
D
E
F
G

Arrival
Time
0
6
18
35
6
14
26

Burst Time
11
5
1
8
16
13
10

S-ar putea să vă placă și