Você está na página 1de 9

SCHEDULING

ALGORITHMS

COMMON TERMS
CPU Utilization The percentage of time that the CPU is
busy.
Throughput The number of processes completing in a
unit of time.
Turnaround time The length of time it takes to run a
process from initialization to termination, including all
the waiting time.
Waiting time The total amount of time that a process
is in the ready queue.
Response time The time between when a process is
ready to run and its next I/O request.

FCFS (First Come First Serve)


The scheduler executes jobs to complete in arrival order.
In early FCFS schedulers, the job did not relinquish the CPU even
when it was doing I/O (blocking process).
We will assume a FCFS scheduler that runs when processes are
blocked on I/O, but that is non-preemptive, i.e., the job keeps the
CPU until it blocks (say on an I/O device).
FCFS scheme is not useful in scheduling interactive users because it
cannot guarantee good response time.

Process Burst Time


P1 24
P2
P3

3
3

With FCFS, the process that requests the CPU first is allocated the CPU first
Case #1: Suppose that the processes arrive in the order: P1,P2,P3
P1
0

Waiting time for P1

= 0; P2

P2
24

P3
27

= 24; P3 = 27

Average waiting time: (0 + 24 + 27)/3 = 17


Average turn-around time: (24 + 27 + 30)/3 = 27

30

Shortest Job First (SJF)


The SJF algorithm associates with each process the length of its next CPU burst
When the CPU becomes available, it is assigned to the process that has the
smallest next CPU burst (in the case of matching bursts, FCFS is used)
Two schemes:
Non pre-emptive once the CPU is given to the process, it cannot be preempted until it completes its CPU burst
Pre-emptive if a new process arrives with a CPU burst length less than the
remaining time of the current executing process, pre-empt. This scheme is
know as the Shortest-Remaining-Time-First (SRTF).

Non Pre-emptive SJF


Process Arrival Time Burst Time
P1 0.0 6
P2 0.0 4
P3 0.0 1
P4 0.0 5

SJF (non-pre-emptive, simultaneous arrival)

Average waiting time = (0 + 1 + 5 + 10)/4 = 4


Average turn-around time = (1 + 5 + 10 + 16)/4 = 8

Pre-emptive SJF
Process
Arrival Time
P1 0.0 7
P2 2.0 4
P3 4.0 1
P4 5.0 4

Burst Time

SJF (pre-emptive, varied arrival times)

Average waiting time


= ( [(0 0) + (11 - 2)] + [(2 2) + (5 4)] + (4 - 4) + (7 5) )/4
= 9 + 1 + 0 + 2)/4
=3
Average turn-around time
= (16 + 7 + 5 + 11)/4 = 9.75

Priority Based Scheduling


Each process is assigned a priority. Process with highest
priority is to be executed first and so on.
Processes with same priority are executed on first come
first serve basis.
Priority can be decided based on memory requirements,
time requirements or any other resource requirement.

Process Wait Time : Service Time - Arrival


Time
P0

9-0=9

P1

6-1=5

P2

14 - 2 = 12

P3

0-0=0

Wait time of each process is following


Average Wait Time: (9+5+12+0) / 4 = 6.5

Você também pode gostar