schedule
schedule
OBJECTIVES
• Dispatcher module gives control of the CPU to the process selected by the
short-term scheduler; this involves:
• Switching context
• Switching to user mode
• Jumping to the proper location in the user program to restart that program
• Dispatch latency – time it takes for the dispatcher to stop one process and
start another running
SCHEDULING CRITERIA
1. Fixed-instance
2. Periodic
3. Aperiodic
4. Sporadic
FIXED-INSTANCE TASKS
PERIODIC TASKS
• Processor utilization
U > 1 : CPU is overloaded
U ≤ 1 : not overload
APERIODIC TASKS
• Turn Around Time (TAT) is the total time taken for a process to complete its
execution from the moment it enters the system until it finishes. It includes
both the time the process spends executing on the CPU and the time it spends
waiting for CPU time. TAT is measured from the start of the process to its
completion and is often used to evaluate the overall efficiency of a scheduling
algorithm.
• Waiting Time (WT) refers to the total amount of time a process spends
waiting in the ready queue before it can be executed on the CPU. It is the time
interval between the process's arrival in the ready queue and the start of its
execution. WT measures the extent to which processes have to wait for CPU
time and is a crucial factor in assessing the efficiency of a CPU scheduling
algorithm.
SCHEDULING ALGORITHMS
• Non-preemptive
• Preemptive
NON-PREEMPTIVE SCHEDULING ALGORITHM
• Timeline:
- Use whatever heuristics the designer chooses to come up with an acceptable schedule
NON-PREEMPTIVE SCHEDULING ALGORITHM
Scheduling four tasks using FCFS. Deadlines are marked with stars
NON-PREEMPTIVE SCHEDULING ALGORITHM
• Shortest-job next:
Scheduling four tasks using shortest-task first. Deadlines are marked with stars
NON-PREEMPTIVE SCHEDULING ALGORITHM
• Earliest-deadline first:
Scheduling tasks using earliest-deadline first scheduler. Deadlines are marked with stars
NON-PREEMPTIVE SCHEDULING ALGORITHM
• Least-slack first:
Scheduling tasks using least-slack first scheduler. Latest start times are marked with diamonds.
SCHEDULING ALGORITHMS
• Non-preemptive
• Preemptive
PERIODIC TASK
• execute once per period
• not possible for periodic tasks to start execution before their period
• A switch is only made if absolutely necessary: we will switch only if not switching will
cause a task to miss a deadline (slack time of a task goes to zero).
PREEMPTIVE SCHEDULING ALGORITHM
• Timeline scheduling:
A task k can be represented as a pair (Ck, Tk)
Ck: the worst-case computation time
Tk: the period
Processor utilization
If U < 1: we can always schedule these tasks over a period of the least
common multiple of the periods (super period)
PREEMPTIVE SCHEDULING ALGORITHM
• Timeline scheduling:
Example of three tasks: Task1 (1, 6) – Task2 (9, 14) and Task3 (4, 21)
processor utilization: U =
Earliest-deadline-first algorithm
PREEMPTIVE SCHEDULING ALGORITHM
• Timeline scheduling:
Example of three tasks: Task1 (1, 6) – Task2 (9, 14) and Task3 (4, 21)
Round-robin (RR) idea is that a task is allowed to run at most n units of time
(called a time slice) before it is pre-empted and placed back into the ready
queue.
Each time a task is scheduled, a timing interrupt is set at the appropriate time
in the future.
If the task yields the processor early, the associated timing interrupt is
cancelled.
We cannot, however, use this round robin for real-time systems, as it does
not take into account any deadlines.
Earliest-deadline first
o At any time, the task that is executing is the task has the earliest deadline
o If tasks can be scheduled in such a way for all tasks to meet their deadlines
o Task, has less slack time prior to its deadline, will be executed
o Better under certain conditions than earliest-deadline first when dealing with
multiple processing units
PREEMPTIVE SCHEDULING ALGORITHM
• Fixed Priority-based preemptive scheduling :
Consider three process, all arriving at time zero, with total execution time of 10, 20 and 30
units respectively.
Each process spends the first 20% of execution time doing I/O, the next 70% of time doing
computation, and the last 10% of time doing I/O again.
The operating system uses a shortest remaining time first scheduling algorithm and schedules a
new process either when the running process gets blocked on I/O or when the running process
finishes its compute burst. Assume that all I/O operations can be overlapped as much as
possible. For what percentage of does the CPU remain idle?