Uniprocessor Scheduling I Chapter 9 Goals of Scheduling

  • Slides: 22
Download presentation
Uniprocessor Scheduling I Chapter 9

Uniprocessor Scheduling I Chapter 9

Goals of Scheduling z Quick response time z Fast throughput z Processor efficiency

Goals of Scheduling z Quick response time z Fast throughput z Processor efficiency

Type of Scheduling (1) z Long-term y performed when new process is created y

Type of Scheduling (1) z Long-term y performed when new process is created y The decision to add to the pool of processes to be executed (chapter 3, process control) z Medium-term y swapping y The decision to add to the number of processes that are partially or fully in main memory (chapter 7 and 8, control structure)

Types of Scheduling z Short-term y which ready process to execute next y decision

Types of Scheduling z Short-term y which ready process to execute next y decision as to which ready process will be executed by the processor (chatter 9 and 10) z I/O y decision as to which process’s pending I/O request shall be handled by available I/O device (chapter 11)

Scheduling and Process State Transition New Long-term scheduling Ready, suspend Long-term scheduling Ready Medium-term

Scheduling and Process State Transition New Long-term scheduling Ready, suspend Long-term scheduling Ready Medium-term scheduling Blocked, suspend Blocked Medium-term scheduling Running Short-term scheduling Exit

A Seven-State Model - States z Ready: The process is in main memory and

A Seven-State Model - States z Ready: The process is in main memory and available for execution. z Blocked: The process is in main memory and awaiting an event. z Blocked, suspend: The process is in secondary memory and awaiting an event. z Ready, suspend: The process is in secondary memory but is available for execution as soon as it is loaded into main memory.

Queuing Diagram for Scheduling Long-term scheduling Batch jobs Time-out Ready Queue Short-term scheduling Release

Queuing Diagram for Scheduling Long-term scheduling Batch jobs Time-out Ready Queue Short-term scheduling Release Processor Medium-term scheduling Interactive users Ready, Suspend Queue Medium-term scheduling Blocked, Suspend Queue Blocked Queue Event Occurs Event Wait

Long-Term Scheduling z Determines which programs are admitted to the system for processing z

Long-Term Scheduling z Determines which programs are admitted to the system for processing z Controls the degree of multiprogramming z More processes, smaller percentage of time each process is executed

Medium-Term Scheduling z Swapping z Based on the need to manage multiprogramming

Medium-Term Scheduling z Swapping z Based on the need to manage multiprogramming

Short-Term Scheduling z Known as the dispatcher z Invoked when an event occurs y

Short-Term Scheduling z Known as the dispatcher z Invoked when an event occurs y clock interrupts y I/O interrupts y operating system calls y signals

Short-Tem Scheduling Criteria z User-oriented y Related to the behavior of the system as

Short-Tem Scheduling Criteria z User-oriented y Related to the behavior of the system as perceived by the individual user or process. y Response Time: Elapsed time between the submission of a request until there is output. z System-oriented y The focus if on effective and efficient utilization of the processor

Short-Term Scheduling Criteria z Performance-related y Performance-related criteria are quantitative and generally can be

Short-Term Scheduling Criteria z Performance-related y Performance-related criteria are quantitative and generally can be readily measured. y measurable such as response time and throughput z Not performance related y predictability: a given job should run in about the same amount of time and at about the same cost regardless of the load on the system

Priorities z Scheduler will always choose a process of higher priority over one of

Priorities z Scheduler will always choose a process of higher priority over one of lower priority z Have multiple ready queues to represent each level of priority z Lower-priority may suffer starvation y allow a process to change its priority based on its age or execution history

Priority Queuing RQ 0 A set of queues to instead of a single ready

Priority Queuing RQ 0 A set of queues to instead of a single ready queue Release Dispatch Processor RQ 1 . . . Admit RQn Priority [RQi] >[RQj] Preemption for i<j Event Wait Event occurs Blocked Queue

Decision Mode z Nonpreemptive y Once a process is in the running state, it

Decision Mode z Nonpreemptive y Once a process is in the running state, it will continue until it terminates or blocks itself for I/O z Preemptive y Currently running process may be interrupted and moved to the Ready state by the operating system y Allows for better service since any one process cannot monopolize the processor for very long

An Example for Scheduling Policies Process 1 Arrival Time 0 2 2 3 6

An Example for Scheduling Policies Process 1 Arrival Time 0 2 2 3 6 3 4 4 6 4 5 5 8 2 Service Time

First-Come-First-Served (FCFS) 0 5 10 15 20 1 2 3 4 5 z Each

First-Come-First-Served (FCFS) 0 5 10 15 20 1 2 3 4 5 z Each process joins the Ready queue z When the current process ceases to execute, the oldest process in the Ready queue is selected

Turnaround Time and Service Time z Turnaround Time Tq - the total time that

Turnaround Time and Service Time z Turnaround Time Tq - the total time that the item spends in the system (waiting time plus service time, or finish time mines arrival time). z Service Time Ts - Finish Time minus Start Time. z Normalized Turnaround Time - the ratio of turnaround time to service time Tq / T s

FCFS -Normalized Turnaround Time Process Arrival Serve Start Finish Turnaround Tq/Ts Time Time Tq

FCFS -Normalized Turnaround Time Process Arrival Serve Start Finish Turnaround Tq/Ts Time Time Tq A 0 1 1 1 B 1 100 1 C 2 1 102 100 D 3 100 102 202 199 100 26 Mean

Difficulties with First-Come-First-Served z A short process may have to wait a very long

Difficulties with First-Come-First-Served z A short process may have to wait a very long time before it can execute z Favors CPU-bound processes y CPU-bound processes: the processes mostly use processor. y I/O processes have to wait until CPU-bound process completes

Round-Robin q=1 5 0 1 2 3 4 5 0 2 2 3 10

Round-Robin q=1 5 0 1 2 3 4 5 0 2 2 3 10 4 5 6 6 15 20 Ready Time 7 8 8 9 10 14 13 11 12 16 z Uses preemption based on a clock z An amount of time is determined that allows each process to use the processor for that length of time z Next ready job is selected.

Round-Robin q=4 5 0 1 2 3 4 5 0 2 Ready Time P

Round-Robin q=4 5 0 1 2 3 4 5 0 2 Ready Time P 2 rest part ready time is 7 P 4 rest part ready time is 15 P 5 ready time is 8 10 15 20 7 4 Ready Time 6 15 8 P 4 rest part ready time is 15 P 5 ready time is 8