You are on page 1of 33

Libyan academy / Misrata Branch department of computer science

Scheduling algorithm best for scheduling of the CPU


Prepared by:
Basma M.Algubi Raheel M.Bakaa Najat M.Eljamel Submitted in partial fulfillment of the requirement of the distributed system course

Present to:
Dr. Ahmed Almaghrawi

1) 2) 3) 4) 5) 6) 7)

overview Introduction Scheduling Criteria Type of scheduling Scheduling Algorithms proposed conclusion

In this presentation Will identify the scheduling criteria,

scheduling types, and basic scheduling algorithms


we a algorithm proposal combines desirable features of CPU

scheduler to maximize CPU utilization, response time and minimize waiting time and turnaround time .

Scheduling Deciding which process should occupy a resource (CPU)


(CPU (horsepower)) I want to ride it Whose turn is it?

Process 1

Process 2

Process 3

The scheduler is a component of an operating system that determine which process


should be run and when. Scheduling algorithms is the mechanism which the resource CPU is allocated to a process, which requires careful attention to assure fairness and avoid process starvation.

1-Utilization/Efficiency.

2-Throughput.
3-Turnaround time. 4- Response Time. 5- Waiting time 6-Fairness.

Scheduling can be divided into two categories:


1- Non Preemptive: 2- Preemptive

1- Long term scheduling 2- Medium term scheduling 3- Short term scheduling (or dispatching):

1. first come first serve ( FCFS) 2. shorter time first (SJF) 3. Round Robin (RR) 4. Priority

5. Multilevel queue

1.

first come first serve ( FCFS) Tasks are performed by priority and arrival FIFO is a non-preemptive algorithm Here disadvantages non-optimal utilization of the processor and never considered inappropriate for use in interactive systems

1.

first come first serve ( FCFS)

P1 3 time unit

P2 4 time unit

P3 2 time unit

PCB

PCB

PCB

CPU

1.

first come first serve ( FCFS)


CPU burst time(ms) 8 4 9 Process P1 P2 P3

P4

P1 0
waiting time p1= 0 &

8
p2 = 8

P2 12
& p3 = 12

P3 21
& P4=21

P4 26

average waiting time =10.25

2. shorter job first (SJF)


1.In this algorithm process is performed with a short time first 2.of the Advantages Reduce waiting time 3.Two types ( preemptive , non- preemptive) 4.processes with long-time execution may occur starvation

2. shorter time first (SJF)

P1 3 time unit PCB

P2 4 time unit

P3 2 time unit

PCB

PCB

CPU

2 . shorter time first (STF)


CPU burst time(ms) 8 4 9 Arrival Time 0 1 2 3 Process P1 P2 P3 P4

Non Preemptive
P1 0 waiting time p1= 0 8 &

P2 p2 = 7 12 &

P4 17 p3 = 15

P3 26 & P4=9

Average waiting time = 10.25 Preemptive :P1 0


waiting time p1= 9 &

P2 1
p2 = 0 &

P4 5
p3 = 15

P1 10
& P4=2

P3 17 26

Average waiting time = 6.5

3. Round Robin (RR)


1) 2) 3) 4)

fair distribution of time between processes Is preemptive scheduler Starvation not occur for process algorithm like FCFS but here each time Execution process defined within the CPU.

5) 6)

If the duration of very large Quantum became like FCFS If the duration of a very small Quantum mobility processes have become a waste of time

3. Round Robin (RR) Quantum = 2

P1 3 time unit PCB

P2 4 time unit

P3 2 time unit

PCB

PCB

CPU

3. Round Robin (RR) Quantum = 2

P2 4 time unit

P3 2 time unit

PCB

PCB

CPU

P1 1 time unit PCB

3. Round Robin (RR) Quantum = 2

P3 2 time unit

P1 1 time unit PCB

PCB

CPU

P2 2 time unit

PCB

3. Round Robin (RR) Quantum = 2

P1 1 time unit
PCB

P2 2 time unit

PCB

CPU

P3 2 time unit

PCB

3. Round Robin (RR)


CPU burst time(ms) Process Arrival Time

8
4 9

P1
P2 P3 P4

0
1 2 3

Quantum = 4 P1
0 4

P2
8
&

P3
12

P4
16
&

P1
20

P3
24

P4
25

P3
26

waiting time p1= 12

p2 = 3

p3 = 13

& P4=17

Average waiting time = 11.25

4- Priority Scheduling (PS): 1)Implemented depending on the priority of process 2)Greater priority process executed in the first 3)The priority is an integer number 4) lower numbers are used to represent higher priorities 5) Starvation : low priority processes may never execute. .Solution [ Aging : as time progresses increase the priority of the process].

4. priority
Priority 2 1 3 4 Burst time 8 4 9 5 Process P1 P2 P3 P4

P2
0 4

P1
12
& p2 = 0

P3
21
& p3 = 12

P4
26
& P4=21

waiting time p1= 4

Average waiting time = 11.5

5-Multilevel queue 5-1Multilevel Queue Scheduling Algorithm


1) Is divided queue ready for the implementation of processes to several queues 2) Each queue is determined its own scheduling algorithm and the quality of the processes that will be placed in this queue 3) process remain permanently on a one queue (do not move from one queue to another) 4) process in the queue depends on several factors (size of the operation, priority process, the type of process).

5-Multilevel queue 5-2 feedback multilevel Scheduling Algorithm A process can move between the various queues; aging can be implemented this way.

In this algorithm was merged two algorithms RR and SJF to try to determine the quantum time for RR algorithm and disposal of the starvation in SJF. 1-calculate the average of the time needed at finish the process which is in the queue 2- The result of the average is considered as quantum 3- Round Robin algorithm is applied on the process which has short time must the run first

4- Repeat the previous steps until the end

CPU burst time(ms)

Process

Arrival Time

8
4 9 5

P1
P2 P3 P4

0
1 2 3

Q1=Average =
P2 P4

= 6.5
P1 P3

Q2=Average = P1

4 P3 26
&

92 =

15.5

22

23.5
waiting time p1= 18.5

p2 = 0

&

p3= 15

& P4=1

Average waiting time = 7.875

Quantum = 4+4+3+1/4 Q=3

P1 4 time unit

P2 3 time unit

P3 4 time unit

P4 1 time unit

PCB

PCB

PCB

PCB

CPU

Quantum = 4+4+3+1/4 Q=3

P1 4 time unit

P3 4 time unit

PCB

PCB

CPU

Quantum = 4+4+3+1/4 Q=3

P3 4 time unit

PCB

CPU P1 1 time unit PCB

Quantum = 1+1/2 Q=1

P1 1 time unit

PCB

CPU P3 1 time unit PCB

Quantum = 1+1/2 Q=1

P3 1 time unit

P3 1 time unit

PCB

PCB

CPU

The given table gives a comparison between RR,SJF and PROPOSED algorithms

Context
time 3 7 4

Turnaround
time 13 17.75 15.125

Average waiting
time 6.5 11.25 7.5

Scheduling
algorithm SJF RR proposed algorithm

Conclusion
Comparison of various types of algorithms, examining the advantages and drawbacks of various algorithms we can proposed a new scheduling algorithm which can solve drawbacks of discussed algorithms We Increase the Performance, Throughput and decrease the Turnaround Time by solves Round Robin with SJF. advantages of algorithms proposed 1- Calculate the average burst time of processes and is regarded as quantum time (time

quantum variable in each cycle)


2- Shortest job are completed in one time. 3- Efficiency:-medium. 4- context time :- Low (comparison to Round Robin Algorithm)

FCFS

SJF

RR

PS

You might also like