Operating Systems ECE 344 Introduction to Scheduling Policies

  • Slides: 11
Download presentation
Operating Systems ECE 344 Introduction to Scheduling Policies Ashvin Goel ECE University of Toronto

Operating Systems ECE 344 Introduction to Scheduling Policies Ashvin Goel ECE University of Toronto

Overview q Scheduler overview q Scheduling goals Batch systems o Interactive systems o q

Overview q Scheduler overview q Scheduling goals Batch systems o Interactive systems o q Scheduling policies Batch scheduling policies o Interactive scheduling policies o 2

Overview of Thread Scheduler q A thread scheduler implements the threads abstraction o Allows

Overview of Thread Scheduler q A thread scheduler implements the threads abstraction o Allows running threads concurrently and in parallel q Scheduler runs when a thread calls threads API q When scheduler runs, it may run another thread_create thread_exit Running Ready Exited thread_yield thread_wakeup thread_sleep Blocked 3

Scheduler Mechanism q Scheduler runs another thread by Suspending current thread o Running another

Scheduler Mechanism q Scheduler runs another thread by Suspending current thread o Running another thread by resuming this thread o Thread switching impl. is called scheduling mechanism o q OS generally implements preemptive scheduling o Scheduler can suspend running thread at any time run thread_create current thread Ready thread_wakeup thread_exit Running thread_yield preemptive thread_yield Exited thread_sleep Blocked 4

Scheduling Policy q Several threads may be ready to run at any time q

Scheduling Policy q Several threads may be ready to run at any time q Which thread should the scheduler choose to run? q Choice depends on scheduling policy Chooses next thread to run, e. g. , highest priority o Decides whether and when to preempt this thread o Which thread torun run? current thread Ready Many threads are ready to run Running Exited preemptive thread_yield Blocked One scheduling mechanism, many scheduling policies! 5

Overview q Scheduler overview q Scheduling goals Batch systems o Interactive systems o q

Overview q Scheduler overview q Scheduling goals Batch systems o Interactive systems o q Scheduling policies Batch scheduling policies o Interactive scheduling policies o 6

CPU-Bound and IO-Bound Programs q Programs alternate between performing computation and IO, called CPU

CPU-Bound and IO-Bound Programs q Programs alternate between performing computation and IO, called CPU and IO bursts o A CPU-bound program has frequent CPU bursts § E. g. , matrix multiply o An IO-bound program has frequent IO bursts § E. g. , web server q When a program performs IO o q Program needs to wait for IO to finish, so CPU is not needed Scheduler runs another program to keep CPU busy o Improves CPU utilization 7

Common Computer Systems q Batch systems Long running, CPU-bound programs (jobs) o No interactive

Common Computer Systems q Batch systems Long running, CPU-bound programs (jobs) o No interactive users, minimal time constraints o E. g. , report generation, big data processing o q Interactive (or general-purpose) systems Short running, IO-bound programs o Interactive users, response time constraints o E. g. , desktop, mobile environments o 8

Scheduling Goals q q Scheduler aims to improve different metrics for each type of

Scheduling Goals q q Scheduler aims to improve different metrics for each type of system Batch systems CPU Utilization: % of time that CPU is busy (not idle) o Throughput: number of jobs that complete per unit time o Turnaround time: time needed from start to finish of job o turnaround time = processing time (running) + waiting time (not running) q Interactive systems o Response time: time between receiving request and producing response 9

Summary q A scheduling mechanism is the method by which a scheduler runs threads

Summary q A scheduling mechanism is the method by which a scheduler runs threads o q Involves switching threads A scheduling policy dictates Which thread is run next o When the thread stops running o q Scheduling policies aim to improve performance o Batch systems, with long-running, CPU bound jobs § Improve throughput and reduce waiting time o Interactive systems, with short-running IO bound jobs § Improve response time q Next lectures describe scheduling policies 10

Think Time q q Is there a difference between throughput and CPU utilization? If

Think Time q q Is there a difference between throughput and CPU utilization? If so, why? Why does improving (reducing) the response time reduce throughput as well? 11