1.32k likes | 1.53k Views
Processor Scheduling. Scheduling is the activity of selecting the next Job / Process / Request to be handled by a Server/CPU. Preemption Scheduling : A request being processed is preempted in order to provide service to other requests in the system.
E N D
Processor Scheduling Scheduling is the activity of selecting the next Job / Process / Request to be handled by a Server/CPU. Preemption Scheduling: A request being processed is preempted in order to provide service to other requests in the system. It is for providing fair services to all the requests, or servicing the superior request. Non Preemptive Scheduling: A nonpreemptive scheduling / server always processes a scheduled request / job to completion. OS/ProcSche/NI2008
CPU scheduling criteria • CPU Utilization – Percentage of Time that the processor is busy. • Throughput – how many jobs finished/unit time? • No of processes completed per unit of time. • Turnaround Time –how long from job submission to job termination? • Interval of time between the submission of a process and its completion. Includes actual execution time + time spent waiting for resources, including the processor. • Response Time – how long (on average) does it take to get a “response”? • For an interactive process, this is the time from submission of a request/job until the response begins to be received. • Missed deadlines – were any deadlines missed? OS/ProcSche/NI2008
CPU scheduling criteria • Delay Time / CPU Latency Time: • Delay caused in selecting a process for execution • Burst/Service Time: • Actual time taken by CPU to completes the process • Weighted Turn around time: • Ratio of the turn around time of a job/process to its own execution requirements. • Deadline: • Time by which a job/process must be completed • Deadline Overrun: • The amount of time by which the deadline of a job/process is exceeded. It can be both positive or negative. • Schedule Length: The total time taken to complete a set of jobs/processes submitted to a server. OS/ProcSche/NI2008
Scheduler options • Priorities • May use priorities to determine who runs next • Amount of memory, Order of arrival, etc.. • Dynamic vs. Static algorithms • Dynamically alter the priority of the tasks while they are in the system (possibly with feedback) • Static algorithms typically assign a fixed priority when the job is initially started. • Preemptive vs. Nonpreemptive • Preemptive systems allow the task to be interrupted at any time so that the O.S. can take over again. OS/ProcSche/NI2008
Types of Scheduling • Scheduling is split into three steps/levels/stages • Long Term Scheduling / Admission Scheduler • ( New state / Admit state) to Ready • Medium Term Scheduling / Memory Scheduler • ( Ready / Suspended / Blocked / waiting) • Short Term Scheduler / CPU scheduler • ( Preemptive / Non-Preemptive) • ( Ready to Running State) OS/ProcSche/NI2008
Types of Scheduling • Long Term Scheduling: • When to initiate the processing of a job / process. Which programs are admitted to the system for processing. The others are kept in the input queue until they are selected. • Allocates necessary resources • Make it ready to send to the Medium Term Scheduler. • Medium Term Scheduler: • MTS keeps track of states of processes admitted for processing and prepares for execution on the CPU. • It determines which processes should be kept in memory and which one kept on disk (virtual memory). • The decision to add to the number of processes that are partially or fully in main memory. • Performs memory swapping in/out. OS/ProcSche/NI2008
Types of Scheduling • Short Term Scheduling: The short term scheduler is invoked whenever an event occurs that may lead to the suspension of the current process or that may provide an opportunity to preempt a currently running process in favor of another. Event are . • Clock interrupts • I/O interrupts • Operating system calls • Signals STS picks one process from the list of ready processes for execution on the CPU, and hands it to the Dispatching Mechanism. Dispatching loads the state of the selected process – contents of the PSW and CPU registers – into the CPU and allows the CPU to resume execution of the process. OS/ProcSche/NI2008
Scheduling policies / Algorithms • First-Come, First Served (FIFO) • Shortest Job First (non-preemeptive) • Shortest Job First (with preemption) ( Shortest Remaining Time Next ) • Highest Response Ratio Next Scheduling • Shortest Job Next • Deadline Scheduling • Priority Scheduling • Real-Time Scheduling • Round-Robin Scheduling OS/ProcSche/NI2008
Scheduling policies (Preemptive) • Round Robin Scheduling • Heavily loaded system • Two Queues • Multiple Queues • Guaranteed Scheduling • Lottery Scheduling • Fair Share scheduling OS/ProcSche/NI2008
First-Come, First-Served (FIFO) • Start jobs in the order they arrive (FIFO queue) • Run each job until completion OS/ProcSche/NI2008
First-Come, First-Served (FIFO) • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Process Time Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Arrival Times of the Jobs OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 5 4 6 5 7 5 8 2 10 OS/ProcSche/NI2008
0 5 10 15 20 First-Come, First-Served (FIFO) Total time taken, from submission to completion • Start jobs in the order they arrive (FIFO queue) • Run each job until completion Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 5 9 4 6 5 7 12 5 8 2 10 12 OS/ProcSche/NI2008
Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Same Job Mix OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 2 2 6 1 3 4 4 7 4 6 5 9 5 8 2 1 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Job First • Select the job with the shortest (expected) running time • Non-Preemptive Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 0 3 2 2 6 1 7 3 4 4 7 11 4 6 5 9 14 5 8 2 1 3 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 Same Job Mix OS/ProcSche/NI2008
0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008
0 5 10 15 20 Shortest Remaining Time • Preemptive version of SJF Arrival Processing Turnaround Process Time Time Delay Time 1 0 3 2 2 6 3 4 4 4 6 5 5 8 2 OS/ProcSche/NI2008