copy of final ppt
DESCRIPTION
pptTRANSCRIPT
1
Process Scheduling
Neha Bansal 1055Nikita Agarwal 1056Nirmal Porwal 1057Nishant Namdeo 1058Nitesh Vakhare 1059Vishwas Reddy 1060
IACSD - Pune
2
Overview
1. Process 2. Process states 3. Process Scheduling 4. Type of Schedulers.5. Basic Concepts.6. CPU Scheduler.
a. Non-preemptive scheduling.b. Preemptive scheduling.
7. Scheduling Criteria.
3
8. Scheduling Algorithms.a. FCFS .b. SJF.c. Priority.d. Round Robin.
9. Time Quantum and Context Switch Time.10.Any Queries ?
4
1. What is process ?The process is a program in execution. It’s a
unit of work in a system.
2. Process statesNew -The process is being created.Ready -The process is waiting to be assigned to a processor.Running -Instructions are Being executed.Waiting -The process is waiting for some event to occur(such as an I/O completion or reception of signal).Terminated -The process has finished execution.
New Terminated
Ready
Waiting
Running
Admitted
I/O or event Completion
Scheduler Dispatch
InterruptExit
I/O or Event Wait
Figure 1 : Diagram of process states
3. What is process scheduling ?
When a computer is multi-programmed, it frequently has multiple processes competing for the CPU at the same time. Multiprogramming is helpful to maximize CPU utilization.
4. Type of schedulers.
a. Long-term schedulingThe decision to add to pool of processes to be
executed.b. Mid-term scheduling
The decision to add to the number of processes that are partially or fully in memory.c. Short-term scheduling
Decision as to which available process will be executed.d. I/O scheduling
Decision as to which process’s pending request shall be handled by an available I/O device.
5. Basic Concepts
A
B
Long CPU Burst IO Request (wait)
Short CPU burst IO Request (wait) Time
A spends most of his time computing, it is called compute-boundB spends most of his time waiting for I/O, it is called I/O-bound
Histogram of CPU-burst Times
Figure 2 : Histogram of CPU-burst Times
10
6. CPU scheduler
a. Non preemptive Scheduling- picks a process to run- lets it run until it blocks, terminates or voluntary releases the CPU- after clock interrupt, resume the process that was running before
b. Preemptive Scheduling- picks a process to run- after a maximum amount of some fixed time suspends it (if still running)- picks another process to run (if any available)- requires clock
11
7 . Scheduling Criteria
CPU utilization – keep the CPU as busy as possible
Throughput – Number of processes that complete their execution per time unit
Turnaround time –Amount of time to execute a particular process
.
Response time –Amount of time it takes from when a request was submitted until the start of a response (not time for output) (for time- sharing environment)
Waiting time – Amount of time a process has been waiting in the ready queue. Quite representative
7 . Scheduling Criteria (Contd..)
13
8.Scheduling Algorithms
a. FCFS (First Come First Served)b. SJF (Shortest Job First)c. Priority Schedulingd. RR (Round Robin Scheduling)
a. FCFS (First Come First Served)Is non-preemptive
Process Burst TimeP1 24 P2 3 P3 3
Suppose that the processes arrive in the order: P1 , P2 , P3 , all at the same time. The Gantt Chart for the schedule is:
Waiting time for P1 = 0; P2 = 24; P3 = 27Average waiting time: (0 + 24 + 27)/3 = 17
P1 P2 P3
24 27 300
• Suppose that the processes arrive in the order
P2 , P3 , P1 .
• The Gantt chart for the schedule is:
• Waiting time for P1 = 6; P2 = 0; P3 = 3
• Average waiting time: (6 + 0 + 3)/3 = 3• Much better than previous case.• Convoy effect short process behind long
process.
a. FCFS - First Come First Served (contd..)
P1P3P2
63 300
0 5 10 15 20
12345
Figure 3 : FCFS working concept
a. FCFS - First Come First Served (contd..)
b. 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.
Two schemes: Non-preemptive – Once CPU given to the process it
cannot be preempted until completes its CPU burst.Preemptive – If a new process arrives with CPU burst
length less than remaining time of current executing process, preempt.This scheme is know as the Shortest-Remaining-Time-First (SRTF).
Process Arrival Time Burst TimeP1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4
Gantt Chart
Average waiting time = (0 + 6 + 3 + 7)/4 - 4
b. SJF (contd..)
P1 P3 P2
73 160
P4
8 12
• Non-Preemptive Example
b. SJF (contd..) • Preemptive Example
Process Arrival Time Burst TimeP1 0.0 7 P2 2.0 4 P3 4.0 1 P4 5.0 4
Gantt Chart
Average waiting time = (9 + 1 + 0 +2)/4 - 3
P1 P3P2
42 110
P4
5 7
P2 P1
16
0 5 10 15 20
12345
b. SJF (contd..)
c. Priority Scheduling
•A priority number (integer) is associated with each process,
• Internal, e.g., by resource needs• External, e.g., by user priority
•The CPU is allocated to the process with the highest priority (smallest integer highest priority).
• Non-preemptive or PreemptiveExample
Proc ArrivalBurst PriorityP1 0 10 3P2 1 1 1P3 2 2 3P4 4 1 4P5 8 5 2
• SJF is a priority scheduling where priority is the predicted next CPU burst time.
• Problem Starvation – low priority processes may never execute.
• Solution Aging – as time progresses increase the priority of the process.
c. Priority Scheduling
23
d. Round Robin (RR)
Each process gets a small unit of CPU time (time quantum), usually 10-100 milliseconds. After this time has elapsed, the process is preempted and added to the end of the ready queue.
If there are n processes in the ready queue and the time quantum is q, then each process gets 1/n of the CPU time in chunks of at most q time units at once. No process waits more than (n-1)q time units.
Example of RR with Time Quantum = 20
Process Burst TimeP1 53P2 17P3 68P4 24
The Gantt chart is:
P1 P2 P3 P4 P1 P3 P4 P1 P3 P3
0 20 37 57 77 97 117 121 134 154 162
0 5 10 15 20
12345
d. Round Robin (RR) Concept
9. Time Quantum and Context Switch Time.
Performance• large FIFS
• q small q must be large with respect to context switch, otherwise overhead is too high.
Typically, higher average turnaround than SJF, but better response.
Any queries ?
28
Thank you !