scheduling
scheduling
Lesson Schedule
1.Introduction to scheduling, key terms related to scheduling,
Compare and contrast different non-preemptive and
preemptive scheduling algorithms
2. Scheduling process,
3. Fair share scheduler
4. System call for time, Clock profile
Learning outcomes
•Arrival Time: The time at which the process arrives in the ready queue.
•Completion Time: The time at which the process completes its execution.
•Turn Around Time: Time Difference between completion time and arrival time.
Turn Round Time: Minimum turn around time (Turn Around Time =
Completion Time – Arrival Time)
Waiting Time: The Scheduling algorithm does not affect the time
required to complete the process once it has started performing.
Minimum waiting time
Response Time: In a collaborative system, turnaround time is not the best option. The process may
produce something early and continue to compute the new results while the previous results are
released to the user. Therefore another method is the time taken in the submission of the application
process until the first response is issued.
Types of CPU Scheduling
Algorithms
Non-Preemptive
Preemptive
Scheduling: Non-
Scheduling: Preemptive
Preemptive scheduling is
scheduling is used when
used when a process
a process switches from
terminates , or when a
running state to ready
process switches from
state or from the waiting
running state to waiting
state to the ready state.
state.
Types of CPU Scheduling
Algorithms
First come first serve (FCFS)
Advantages of FCFS
Easy to implement
First come, first serve method
Disadvantages of FCFS
FCFS suffers from Convoy effect.
The average waiting time is much higher than the other
algorithms.
FCFS is very simple and easy to implement and hence not
much efficient.
Shortest job first (SJF)
• Advantages of SJF
• As SJF reduces the average waiting time thus, it is
better than the first come first serve scheduling
algorithm.
• SJF is generally used for long term scheduling
• Disadvantages of SJF
• One of the demerits SJF has is starvation.
• Many times it becomes complicated to predict the
length of the upcoming CPU request
Round robin
• The newly created process is added to the end of the ready queue.
Pre-emptive Priority scheduling
Starvation problem
It is inflexible in nature
Multilevel Feedback Queue
Scheduling
like Multilevel Queue Scheduling
After the time quantum expires, it preempts the process and schedules another
one.
The kernel recalculates the priority of the running process when it comes to user
mode from kernel mode, and it periodically re-adjusts the priority of every "ready-
to-run" process in user mode.
Round robin
Process Scheduling in with multilevel
Unix feedback.
/* Algorithm: schedule_process Input: none Output: none */
{
while (no process picked to execute)
{
for (every process on run queue)
pick highest priority process that is loaded in memory;
if (no process eligible to execute)
idle the machine;
// interrupt takes machine out of idle state
}
remove chosen process from run queue;
switch context to that of chosen process, resume its execution;
}
Example of
process scheduling