Name : Jamsheed Ali
Class No : 06
Topic : An Optimized Round Robin Scheduling Algorithm
for CPU Scheduling in the Operating System
1
CONTENTS
• Abstract
• Introduction
• Simple Round Robin Scheduling Algorithm
• Round Robin Scheduling Algorithm Flow Diagram
• Scheduling Algorithm Objectives
• FCFS Vs RR Algorithms
• Conclusion
2
ABSTRACT
• The main objective of this paper is to develop a new approach for round robin
scheduling which help to improve the CPU efficiency in real time and time
sharing operating system.
• There are many algorithms available for CPU scheduling.
• But we cannot implemented in real time operating system because of high
context switch rates, large waiting time, large response time, large turn around
time and less throughput.
3
INTRODUCTION
• Modern operating system become more complex, when they switch from a
single task to multitasking environment.
• CPU scheduling is an essential operating system task, therefore its scheduling is
central to operating system design.
• When there is more than one process in the ready queue waiting in turn to be
assigned to the CPU, the operating system must decide through the scheduler
the order of execution in which they execute.
• Allocating CPU to a process requires careful attention to assure fairness and
avoid process starvation for CPU.
4
INTRODUCTION (Cont.)
According to Silberchatz, Galvin and Gagne;
• CPU scheduling play a vital role by switching the CPU among several process.
• The aim of operating system to allow a number of processes concurrently in
order to maximize the CPU utilization.
• In a multi-programmed Operating system, a process is executed until it must
wait for the completion or some input-output request.
5
OPERATING SYSTEM SCHEDULING ALGORITHMS
Several Operating System Scheduling Algorithms are:
• First come First serve (FCFS) Scheduling.
• Shortest Job First (SJF) Scheduling.
• Priority Scheduling.
• Round-Robin (RR) scheduling.
6
STEPS: SIMPLE “RR” SCHEDULING ALGORITHMS.
According to Silberchatz, Galvin, Gagne
1. The scheduler maintains a queue of ready processes and a list of blocked and swapped
out processes.
2. The PCB of newly created process is added to end of ready queue. The PCB of
terminating process is removed from the scheduling data structures.
3. The scheduler always selects the PCB at head of the ready queue.
4. When a running process finishes its slice, it is moved to end of ready queue.
5. The event handler perform the following action
a. When a process makes an input -output request or swapped out , its PCB is
removed from ready queue to blocked/swapped out list.
b. When input-output operation awaited by a process finishes or process is swapped in
its process control block is removed from blocked/swapped list to end of ready
queue.
7
ROUND ROBIN SCHEDULING ALGORITHM FLOW
DIAGRAM 8
What is the objective of scheduling algorithm 9
SCHEDULING ALGORITHM OBJECTIVES
we can conclude that a good scheduling algorithm for real time and
time sharing system must possess following characteristics:
• Minimum context switches.
• Maximum CPU utilization(CPU busy).
• Maximum throughput.
• Minimum completion time.
• Minimum waiting time.
• Minimum response time .
10
“FIRST COME FIRST SERVED” VS “ROUND-ROBIN”
ALGORITHMS
• With examples…
11
SCHEDULING ALGORITHMS:
FIRST-COME, FIRST-SERVED (FCFS)
• Example:
• Three processes arrive in order P1, P2, P3.
• P1 burst time: 24
• P2 burst time: 3
• P3 burst time: 3
• Waiting Time
• P1: 0
• P2: 24
• P3: 27
• Completion Time:
• P1: 24
• P2: 27
• P3: 30
• Average Waiting Time: (0+24+27)/3 = 17
• Average Completion Time: (24+27+30)/3 = 27
12
P1 P2 P3
0 24 27 30
• What if their order had been
• P2, P3, P1?
• P1 burst time: 24
• P2 burst time: 3
• P3 burst time: 3
• Waiting Time
• P1: 6
• P2: 0
• P3: 3
• Completion Time:
• P1: 30
• P2: 3
• P3: 6
• Average Waiting Time: (0+3+6)/3 = 3 (compared to 17)
• Average Completion Time: (3+6+30)/3 = 13 (compared
to 27)
P1P2 P3
0 3 6 30
SCHEDULING ALGORITHMS:
FIRST-COME, FIRST-SERVED (FCFS)
• Average Waiting Time: (0+3+6)/3 = 3 (compared to 17)
• Average Completion Time: (3+6+30)/3 = 13 (compared to 27)
• FIFO Pros and Cons:
• Simple
• Short jobs get stuck behind long ones
• Performance is highly dependent on the order in which jobs arrive
13
PROBLEMS WITH FIRST-COME, FIRST-SERVED (FCFS)
• It is non preemptive Algorithm (no option of priority)
• Improper process scheduling.
• Poor resource utilization
(whole operating system slow down due to some slow process)
14
How Can We Improve on This? 15
SCHEDULING ALGORITHMS: ROUND-ROBIN
• In this algorithm the process are dispatched in FIFO manner but
are given limited amount of time called quantum or time slice.
• If a process doe not complete before its CPU time expire, CPU is
preempted and given to the next process waiting in the Que.
16
SCHEDULING ALGORITHMS: ROUND-ROBIN
Example of Round-Robin with Time Quantum = 4
Process Burst Time leave-burst time
P1 24 24-4=20,16,12,8,4
P2 3
P3 3
• The Gantt chart is:
17
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
SCHEDULING ALGORITHMS: ROUND-ROBIN
Process Burst Time
P1 24
P2 3
P3 3
• Waiting Time: Completion Time:
• P1: (10-4) = 6 P1: 30
• P2: (4-0) = 4 P2: 7
• P3: (7-0) = 7 P3: 10
• Average Waiting Time: (6 + 4 + 7)/3= 5.67
• Average Completion Time: (30+7+10)/3=15.67
18
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
CONCLUSION:
• We can see from the above examples average waiting time and average
completion time both are reduced by using our proposed algorithm.
• The reduction of average waiting time and average completion time shows
maximum CPU utilization and minimum response time.
• We observed that proposed algorithm much more efficient as compared to
simple RR algorithm.
19

Round-ribon algorithm presntation

  • 1.
    Name : JamsheedAli Class No : 06 Topic : An Optimized Round Robin Scheduling Algorithm for CPU Scheduling in the Operating System 1
  • 2.
    CONTENTS • Abstract • Introduction •Simple Round Robin Scheduling Algorithm • Round Robin Scheduling Algorithm Flow Diagram • Scheduling Algorithm Objectives • FCFS Vs RR Algorithms • Conclusion 2
  • 3.
    ABSTRACT • The mainobjective of this paper is to develop a new approach for round robin scheduling which help to improve the CPU efficiency in real time and time sharing operating system. • There are many algorithms available for CPU scheduling. • But we cannot implemented in real time operating system because of high context switch rates, large waiting time, large response time, large turn around time and less throughput. 3
  • 4.
    INTRODUCTION • Modern operatingsystem become more complex, when they switch from a single task to multitasking environment. • CPU scheduling is an essential operating system task, therefore its scheduling is central to operating system design. • When there is more than one process in the ready queue waiting in turn to be assigned to the CPU, the operating system must decide through the scheduler the order of execution in which they execute. • Allocating CPU to a process requires careful attention to assure fairness and avoid process starvation for CPU. 4
  • 5.
    INTRODUCTION (Cont.) According toSilberchatz, Galvin and Gagne; • CPU scheduling play a vital role by switching the CPU among several process. • The aim of operating system to allow a number of processes concurrently in order to maximize the CPU utilization. • In a multi-programmed Operating system, a process is executed until it must wait for the completion or some input-output request. 5
  • 6.
    OPERATING SYSTEM SCHEDULINGALGORITHMS Several Operating System Scheduling Algorithms are: • First come First serve (FCFS) Scheduling. • Shortest Job First (SJF) Scheduling. • Priority Scheduling. • Round-Robin (RR) scheduling. 6
  • 7.
    STEPS: SIMPLE “RR”SCHEDULING ALGORITHMS. According to Silberchatz, Galvin, Gagne 1. The scheduler maintains a queue of ready processes and a list of blocked and swapped out processes. 2. The PCB of newly created process is added to end of ready queue. The PCB of terminating process is removed from the scheduling data structures. 3. The scheduler always selects the PCB at head of the ready queue. 4. When a running process finishes its slice, it is moved to end of ready queue. 5. The event handler perform the following action a. When a process makes an input -output request or swapped out , its PCB is removed from ready queue to blocked/swapped out list. b. When input-output operation awaited by a process finishes or process is swapped in its process control block is removed from blocked/swapped list to end of ready queue. 7
  • 8.
    ROUND ROBIN SCHEDULINGALGORITHM FLOW DIAGRAM 8
  • 9.
    What is theobjective of scheduling algorithm 9
  • 10.
    SCHEDULING ALGORITHM OBJECTIVES wecan conclude that a good scheduling algorithm for real time and time sharing system must possess following characteristics: • Minimum context switches. • Maximum CPU utilization(CPU busy). • Maximum throughput. • Minimum completion time. • Minimum waiting time. • Minimum response time . 10
  • 11.
    “FIRST COME FIRSTSERVED” VS “ROUND-ROBIN” ALGORITHMS • With examples… 11
  • 12.
    SCHEDULING ALGORITHMS: FIRST-COME, FIRST-SERVED(FCFS) • Example: • Three processes arrive in order P1, P2, P3. • P1 burst time: 24 • P2 burst time: 3 • P3 burst time: 3 • Waiting Time • P1: 0 • P2: 24 • P3: 27 • Completion Time: • P1: 24 • P2: 27 • P3: 30 • Average Waiting Time: (0+24+27)/3 = 17 • Average Completion Time: (24+27+30)/3 = 27 12 P1 P2 P3 0 24 27 30 • What if their order had been • P2, P3, P1? • P1 burst time: 24 • P2 burst time: 3 • P3 burst time: 3 • Waiting Time • P1: 6 • P2: 0 • P3: 3 • Completion Time: • P1: 30 • P2: 3 • P3: 6 • Average Waiting Time: (0+3+6)/3 = 3 (compared to 17) • Average Completion Time: (3+6+30)/3 = 13 (compared to 27) P1P2 P3 0 3 6 30
  • 13.
    SCHEDULING ALGORITHMS: FIRST-COME, FIRST-SERVED(FCFS) • Average Waiting Time: (0+3+6)/3 = 3 (compared to 17) • Average Completion Time: (3+6+30)/3 = 13 (compared to 27) • FIFO Pros and Cons: • Simple • Short jobs get stuck behind long ones • Performance is highly dependent on the order in which jobs arrive 13
  • 14.
    PROBLEMS WITH FIRST-COME,FIRST-SERVED (FCFS) • It is non preemptive Algorithm (no option of priority) • Improper process scheduling. • Poor resource utilization (whole operating system slow down due to some slow process) 14
  • 15.
    How Can WeImprove on This? 15
  • 16.
    SCHEDULING ALGORITHMS: ROUND-ROBIN •In this algorithm the process are dispatched in FIFO manner but are given limited amount of time called quantum or time slice. • If a process doe not complete before its CPU time expire, CPU is preempted and given to the next process waiting in the Que. 16
  • 17.
    SCHEDULING ALGORITHMS: ROUND-ROBIN Exampleof Round-Robin with Time Quantum = 4 Process Burst Time leave-burst time P1 24 24-4=20,16,12,8,4 P2 3 P3 3 • The Gantt chart is: 17 P1 P2 P3 P1 P1 P1 P1 P1 0 4 7 10 14 18 22 26 30
  • 18.
    SCHEDULING ALGORITHMS: ROUND-ROBIN ProcessBurst Time P1 24 P2 3 P3 3 • Waiting Time: Completion Time: • P1: (10-4) = 6 P1: 30 • P2: (4-0) = 4 P2: 7 • P3: (7-0) = 7 P3: 10 • Average Waiting Time: (6 + 4 + 7)/3= 5.67 • Average Completion Time: (30+7+10)/3=15.67 18 P1 P2 P3 P1 P1 P1 P1 P1 0 4 7 10 14 18 22 26 30
  • 19.
    CONCLUSION: • We cansee from the above examples average waiting time and average completion time both are reduced by using our proposed algorithm. • The reduction of average waiting time and average completion time shows maximum CPU utilization and minimum response time. • We observed that proposed algorithm much more efficient as compared to simple RR algorithm. 19