Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Operating System
Lecture 05
Mohammad Ashraful Islam
Lecturer
Department of Computer Science and Engineering,
Jahangirnagar University
Scheduling Criteria
 CPU utilization – keep the CPU as busy as possible
 Throughput – # of processes that complete their execution per time
unit
 Turnaround time – amount of time to execute a particular process
 TAT = CT - AT
 Waiting time – amount of time a process has been waiting in the ready
queue
 TAT - BT
 Response time – amount of time it takes from when a request was
submitted until the first response is produced, not output (for time-
sharing environment)
Scheduling Algorithm Optimization Criteria
 Max CPU utilization
 Max throughput
 Min turnaround time
 Min waiting time
 Min response time
OS Scheduling Algorithms
 First-Come, First-Served (FCFS) Scheduling
 Shortest-Job-Next (SJN) Scheduling
 Priority Scheduling
 Shortest Remaining Time
 Round Robin(RR) Scheduling
 Multiple-Level Queues Scheduling
First-Come, First-Served (FCFS) Scheduling
 Jobs are executed on first come, first serve basis.
 It is a non-preemptive, pre-emptive scheduling algorithm.
 Easy to understand and implement.
 Its implementation is based on FIFO queue.
 Poor in performance as average wait time is high.
 Implemented in early batch systems.
First-Come, First-Served (FCFS) Scheduling
Process Burst Time
P1 24
P2 3
P3 3
 Suppose that the processes arrive in the order: P1 , P2 , P3
The Gantt Chart for the schedule is:
 Waiting time for P1 = 0; P2 = 24; P3 = 27
 Average waiting time: (0 + 24 + 27)/3 = 17
P P P
1 2 3
0 24 30
27
First-Come, First-Served (FCFS) Scheduling
EXAMPLE DATA:
Process Arrival Burst
Time Time
1 0 8
2 1 4
3 2 9
4 3 5
 Waiting time for P1 = ?; P2 = ?; P3 = ?; P4 = ?
 Average waiting time = ?
 Calculate TAT for each process.
 Average TAT = ?
Shortest-Job-First (SJF) Scheduling
 Associate with each process the length of its next CPU burst
 Use these lengths to schedule the process with the shortest time
 SJF is optimal – gives minimum average waiting time for a given set of
processes
 The difficulty is knowing the length of the next CPU request
 Could ask the user
Shortest-Job-First (SJF) Scheduling

Process Arrival Time Burst Time
P1 0 6
P2 0 8
P3 0 7
P4 0 3
Consider the below processes available in the ready queue for execution, with arrival
time as 0 for all and given burst times.
 SJF scheduling chart
 Average waiting time = (3 + 16 + 9 + 0) / 4 = 7
P3
0 3 24
P4
P1
16
9
P2
Shortest-Job-First (SJF) Scheduling

Process Arrival Time Burst Time
P1 0.0 6
P2 2.0 8
P3 4.0 7
P4 5.0 3
 Determine SJF scheduling chart
 Determine AWT, ATAT
Preemptive Shortest-Job-First (SJF) Scheduling
EXAMPLE DATA:
Process Arrival Service
Time Time
1 0 8
2 1 4
3 2 9
4 3 5
1. Determine Wait Time for each process,
2. Average Waiting Time,
3. TAT for each process,
4. Average TAT.
Preemptive Shortest-Job-First (SJF) Scheduling
EXAMPLE DATA:
Process Arrival Service
Time Time
1 0 8
2 1 4
3 2 9
4 3 5
Determine Wait Time, Average Waiting Time, TAT,
Average TAT.
Shortest Running Time Scheduling
EXAMPLE DATA:
Process Arrival Service
Time Time
1 0 8
2 1 4
3 2 9
4 3 5
Determine Wait Time, Average Waiting Time, TAT,
Average TAT.
Round Robin Scheduling
Round Robin(RR) scheduling algorithm is mainly designed for time-sharing
systems. This algorithm is similar to FCFS scheduling, but in Round
Robin(RR) scheduling, preemption is added which enables the system to
switch between processes.
➢ A fixed time is allotted to each process, called a quantum, for execution.
➢ Once a process is executed for the given time period that process is
preempted and another process executes for the given time period.
➢ Context switching is used to save states of preempted processes.
Round Robin Scheduling
EXAMPLE DATA: Quantum=3
Process Arrival Service
Time Time
1 0 8
2 0 4
3 0 9
4 0 5
Determine Wait Time, Average Waiting Time, TAT,
Average TAT.
Round Robin Scheduling
EXAMPLE DATA:
Process Arrival Service
Time Time
1 0 8
2 1 4
3 2 9
4 3 5
Determine Wait Time, Average Waiting Time, TAT,
Average TAT.
Time Sharing vs Parallel System
 Parallel Processing Systems are designed to speed up the execution of
programs by dividing the program into multiple fragments and processing
these fragments simultaneously. Such systems are multiprocessor systems
also known as tightly coupled systems. Parallel systems deal with the
simultaneous use of multiple computer resources that can include a single
computer with multiple processors, several computers connected by a
network to form a parallel processing cluster or a combination of both.
 Parallel computing is an evolution of serial computing where the jobs are
broken into discrete parts that can be executed concurrently. Each part is
further broken down into a series of instructions. Instructions from each part
execute simultaneously on different CPUs.
Time Sharing vs Parallel System
 Time-sharing is a technique that enables many people, located at various
terminals, to use a particular computer system at the same time. Time-
sharing or multitasking is a logical extension of multi-programming.
Processor's time which is shared among multiple users simultaneously is
termed time-sharing.
 Multiple jobs are executed by the CPU by switching between them, but the
switches occur so frequently. Thus, the user can receive an immediate
response. For example, in transaction processing, the processor executes
each user program in a short burst or quantum of computation. That is,
if n users are present, then each user can get a time quantum. When the user
submits the command, the response time is in few seconds at most.
Thank You

More Related Content

Process Scheduling Algorithms.pdf

  • 1. Operating System Lecture 05 Mohammad Ashraful Islam Lecturer Department of Computer Science and Engineering, Jahangirnagar University
  • 2. Scheduling Criteria  CPU utilization – keep the CPU as busy as possible  Throughput – # of processes that complete their execution per time unit  Turnaround time – amount of time to execute a particular process  TAT = CT - AT  Waiting time – amount of time a process has been waiting in the ready queue  TAT - BT  Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time- sharing environment)
  • 3. Scheduling Algorithm Optimization Criteria  Max CPU utilization  Max throughput  Min turnaround time  Min waiting time  Min response time
  • 4. OS Scheduling Algorithms  First-Come, First-Served (FCFS) Scheduling  Shortest-Job-Next (SJN) Scheduling  Priority Scheduling  Shortest Remaining Time  Round Robin(RR) Scheduling  Multiple-Level Queues Scheduling
  • 5. First-Come, First-Served (FCFS) Scheduling  Jobs are executed on first come, first serve basis.  It is a non-preemptive, pre-emptive scheduling algorithm.  Easy to understand and implement.  Its implementation is based on FIFO queue.  Poor in performance as average wait time is high.  Implemented in early batch systems.
  • 6. First-Come, First-Served (FCFS) Scheduling Process Burst Time P1 24 P2 3 P3 3  Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is:  Waiting time for P1 = 0; P2 = 24; P3 = 27  Average waiting time: (0 + 24 + 27)/3 = 17 P P P 1 2 3 0 24 30 27
  • 7. First-Come, First-Served (FCFS) Scheduling EXAMPLE DATA: Process Arrival Burst Time Time 1 0 8 2 1 4 3 2 9 4 3 5  Waiting time for P1 = ?; P2 = ?; P3 = ?; P4 = ?  Average waiting time = ?  Calculate TAT for each process.  Average TAT = ?
  • 8. Shortest-Job-First (SJF) Scheduling  Associate with each process the length of its next CPU burst  Use these lengths to schedule the process with the shortest time  SJF is optimal – gives minimum average waiting time for a given set of processes  The difficulty is knowing the length of the next CPU request  Could ask the user
  • 9. Shortest-Job-First (SJF) Scheduling  Process Arrival Time Burst Time P1 0 6 P2 0 8 P3 0 7 P4 0 3 Consider the below processes available in the ready queue for execution, with arrival time as 0 for all and given burst times.  SJF scheduling chart  Average waiting time = (3 + 16 + 9 + 0) / 4 = 7 P3 0 3 24 P4 P1 16 9 P2
  • 10. Shortest-Job-First (SJF) Scheduling  Process Arrival Time Burst Time P1 0.0 6 P2 2.0 8 P3 4.0 7 P4 5.0 3  Determine SJF scheduling chart  Determine AWT, ATAT
  • 11. Preemptive Shortest-Job-First (SJF) Scheduling EXAMPLE DATA: Process Arrival Service Time Time 1 0 8 2 1 4 3 2 9 4 3 5 1. Determine Wait Time for each process, 2. Average Waiting Time, 3. TAT for each process, 4. Average TAT.
  • 12. Preemptive Shortest-Job-First (SJF) Scheduling EXAMPLE DATA: Process Arrival Service Time Time 1 0 8 2 1 4 3 2 9 4 3 5 Determine Wait Time, Average Waiting Time, TAT, Average TAT.
  • 13. Shortest Running Time Scheduling EXAMPLE DATA: Process Arrival Service Time Time 1 0 8 2 1 4 3 2 9 4 3 5 Determine Wait Time, Average Waiting Time, TAT, Average TAT.
  • 14. Round Robin Scheduling Round Robin(RR) scheduling algorithm is mainly designed for time-sharing systems. This algorithm is similar to FCFS scheduling, but in Round Robin(RR) scheduling, preemption is added which enables the system to switch between processes. ➢ A fixed time is allotted to each process, called a quantum, for execution. ➢ Once a process is executed for the given time period that process is preempted and another process executes for the given time period. ➢ Context switching is used to save states of preempted processes.
  • 15. Round Robin Scheduling EXAMPLE DATA: Quantum=3 Process Arrival Service Time Time 1 0 8 2 0 4 3 0 9 4 0 5 Determine Wait Time, Average Waiting Time, TAT, Average TAT.
  • 16. Round Robin Scheduling EXAMPLE DATA: Process Arrival Service Time Time 1 0 8 2 1 4 3 2 9 4 3 5 Determine Wait Time, Average Waiting Time, TAT, Average TAT.
  • 17. Time Sharing vs Parallel System  Parallel Processing Systems are designed to speed up the execution of programs by dividing the program into multiple fragments and processing these fragments simultaneously. Such systems are multiprocessor systems also known as tightly coupled systems. Parallel systems deal with the simultaneous use of multiple computer resources that can include a single computer with multiple processors, several computers connected by a network to form a parallel processing cluster or a combination of both.  Parallel computing is an evolution of serial computing where the jobs are broken into discrete parts that can be executed concurrently. Each part is further broken down into a series of instructions. Instructions from each part execute simultaneously on different CPUs.
  • 18. Time Sharing vs Parallel System  Time-sharing is a technique that enables many people, located at various terminals, to use a particular computer system at the same time. Time- sharing or multitasking is a logical extension of multi-programming. Processor's time which is shared among multiple users simultaneously is termed time-sharing.  Multiple jobs are executed by the CPU by switching between them, but the switches occur so frequently. Thus, the user can receive an immediate response. For example, in transaction processing, the processor executes each user program in a short burst or quantum of computation. That is, if n users are present, then each user can get a time quantum. When the user submits the command, the response time is in few seconds at most.