Process Scheduling 1 Chapter 5. Process Scheduling Clock interrupt handling Scheduler goal Traditional UNIX scheduling SVR4 scheduler Solaris 2.x scheduling.

Slides:



Advertisements
Similar presentations
Operating Systems Process Scheduling (Ch 3.2, )
Advertisements

Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D. .
CPU Scheduling Section 2.5.
Chapter 3: CPU Scheduling
1 Traditional Unix Scheduling “Traditional” means –No consideration on realtime processes. –Typically 4.3BSD and SVR3 MFQ-based –Preemptive (time quantum.
Operating System Process Scheduling (Ch 4.2, )
CPU Scheduling CS 416: Operating Systems Design, Spring 2001
Operating System I Process Scheduling. Schedulers F Short-Term –“Which process gets the CPU?” –Fast, since once per 100 ms F Long-Term (batch) –“Which.
Chapter 8 – Processor Scheduling Outline 8.1 Introduction 8.2Scheduling Levels 8.3Preemptive vs. Nonpreemptive Scheduling 8.4Priorities 8.5Scheduling Objectives.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling The key to multiprogramming is scheduling Scheduling is done to meet the goals of –Response time.
1 Multilevel Feedback Queue Scheduling Another way to put a preference on short-lived processes –Penalize processes that have been running longer. Preemptive.
1 Scheduling in Representative Operating Systems.
1 Uniprocessor Scheduling Chapter 9. 2 Aims of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
Operating Systems Process Scheduling (Ch 4.2, )
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Scheduling. Model of Process Execution Ready List Ready List Scheduler CPU Resource Manager Resource Manager Resources Preemption or voluntary yield AllocateRequest.
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Operating System Process Scheduling (Ch 4.2, )
1Chapter 05, Fall 2008 CPU Scheduling The CPU scheduler (sometimes called the dispatcher or short-term scheduler): Selects a process from the ready queue.
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Main Job: Assign processes to be executed by the processor(s) and processes to be loaded in main.
 Scheduling  Linux Scheduling  Linux Scheduling Policy  Classification Of Processes In Linux  Linux Scheduling Classes  Process States In Linux.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms.
CPU Scheduling Chapter 6 Chapter 6.
Chapter 6: CPU Scheduling
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
1 Process Scheduling Chapter 5. 2 Introduction u Policy and implementation u Objectives: u Fast response time u High throughput (turnaround time) u Avoidance.
OPERATING SYSTEMS CPU SCHEDULING.  Introduction to CPU scheduling Introduction to CPU scheduling  Dispatcher Dispatcher  Terms used in CPU scheduling.
Chapter 9 Uniprocessor Scheduling Spring, 2011 School of Computer Science & Engineering Chung-Ang University.
Chapter 6 CPU SCHEDULING.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Operating System Examples - Scheduling
1 Previous lecture review n Out of basic scheduling techniques none is a clear winner: u FCFS - simple but unfair u RR - more overhead than FCFS may not.
Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
Scheduling. Alternating Sequence of CPU And I/O Bursts.
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
1 Scheduling The part of the OS that makes the choice of which process to run next is called the scheduler and the algorithm it uses is called the scheduling.
CPU Scheduling CS 6560: Operating Systems Design.
What Every Developer Should Know about the Kernel Dr. Michael L. Collard 1.
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
Lecture 7: Scheduling preemptive/non-preemptive scheduler CPU bursts
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Response time Throughput Processor efficiency.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Response time Throughput Processor efficiency.
Uniprocessor Scheduling
Chapter 5: Process Scheduling. 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Basic Concepts Maximum CPU utilization can be obtained.
1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.
Traditional UNIX Scheduling Scheduling algorithm objectives Provide good response time for interactive users Ensure that low-priority background jobs do.
CS333 Intro to Operating Systems Jonathan Walpole.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
1 CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
1 Uniprocessor Scheduling Chapter 3. 2 Alternating Sequence of CPU And I/O Bursts.
Operating System Examples - Scheduling. References r er/ch10.html r bangalore.org/blug/meetings/200401/scheduler-
Lecturer 5: Process Scheduling Process Scheduling  Criteria & Objectives Types of Scheduling  Long term  Medium term  Short term CPU Scheduling Algorithms.
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
Uniprocessor Scheduling Chapter 9 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
CPU Scheduling Scheduling processes (or kernel-level threads) onto the cpu is one of the most important OS functions. The cpu is an expensive resource.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
PROCESS MANAGEMENT IN MACH
Applied Operating System Concepts -
Chapter 2 Scheduling.
Uniprocessor Scheduling
Chapter 6: CPU Scheduling
TDC 311 Process Scheduling.
Chapter 9 Uniprocessor Scheduling
Threads Chapter 4.
Uniprocessor Scheduling
Presentation transcript:

Process Scheduling 1 Chapter 5. Process Scheduling Clock interrupt handling Scheduler goal Traditional UNIX scheduling SVR4 scheduler Solaris 2.x scheduling enhancements Scheduling in Mach Other scheduling implementation

Process Scheduling 2 Clock Interrupt Handling H/W clock interrupts the system at fixed time intervals The clock interrupt handler is second priority only to that of power-failure interrupt The clock interrupt handler performs –rearms the h/w clock if necessary –updates CPU usage statistics for the current process

Process Scheduling 3 Clock Interrupt Handling (cont) –performs scheduler-related functions, such as priority recomputation time-slice expiration handling –sends a SIGXCPU signal to the current process if it has exceeded its CPU usage quota –updates the time-of-day clock and other related clocks –handle callouts –wakes up system processes such as the swapper and pagedaemon when appropriate –handle alarm

Process Scheduling 4 Callouts A callout records a function that the kernel must invoke at a later time –e.g. SVR4 –int to_ID = timeout(void (*fn( )), caddr_t arg, long delta); In system context Used for periodic tasks –retransmission of network packets –scheduler and memory management functions –monitoring devices to avoid losing interrupts –polling devices that do not support interrupts

Process Scheduling 5 Callouts (cont) Callout implementation in BSD UNIX Callout listhead t = 2 roundrobin t = 1 schedcpu t = 4 f1 t = 0 f2 time left to fire2377 (a) Callout queue at on instant of time Callout listhead t = 1 roundrobin t = 1 schedcpu t = 4 f1 t = 0 f2 time left to fire1266 (b) Callout queue one tick later

Process Scheduling 6 Alarms A process requests the kernel to send it a signal after a specific amount of time three types of alarms –real-time alarm relates to the actual elapsed time, via a SIGALARM signal high resolution  high accuracy –profiling alarm measures the amount of time the process has been executing, via SIGPROF signal –virtual time alarm monitors only the time spent by the process in user mode, via SIGVTALARM signal

Process Scheduling 7 Scheduler Goals Deliver acceptable performance to each Ap. Categories of applications –interactive spend a lot of time waiting user input system needs to reduce the average time and variance btw user action and application response acceptable delay is about 50 ~ 150ms –batch do not require user interaction, as background jobs criteria: task’s completion time –real-time time-critical with guaranteed bounds on response time

Process Scheduling 8 Traditional Scheduling SVR3, 4.3 BSD Scheduling target –time-sharing, interactive environment with several batch and foreground processes simultaneously Scheduling policy –improve response time of interactive users, while ensuring that low priority, background jobs do not starve

Process Scheduling 9 Traditional Scheduling (cont) Priority-based –priority changes with time –preemptive time-slicing Kernel is nonpreemptible Process priority –0 ~ 49: kernel, 50 ~ 127: process in user mode proc structure –p_pricurrent scheduling priority –p_usrpriuser mode priority –p_cpumeasure of recent CPU usage –p_niceuser-controllable nice factor

Process Scheduling 10 Traditional Scheduling (cont) Sleep priority –kernel value (0 ~ 49) –e.g. terminal input: 28, disk I/O: 20 Priority calculation: schedcpu( ) –every tick, clock handler increments p_cpu for the current process –every second, p_cpu = p_cpu - decay factor; –p_usrpri = PUSER + p_cpu/4 + 2*p_nice; –PUSER is the baseline priority of 50

Process Scheduling 11 Traditional Scheduling (cont) Scheduler implementation 00 0 ~ 3 4 ~ 7 8 ~ ~ ~ ~23... P whichqs PP PP 0110 qs...

Process Scheduling 12 Traditional Scheduling (cont) Situations for context switch –current process blocks on a resource, or exits –priority recomputation procedure results in the priority of another process becoming greater than that of of the current one –current process, or an interrupt handler, wakes up a higher-priority process

Process Scheduling 13 Traditional Scheduling (cont) Analysis –simple and effective –favor I/O-bound jobs –not scale well –no guarantee of CPU usage and response time –kernel is non-preemptive: priority inversion

Process Scheduling 14 SVR4 Scheduler Scheduling class –time sharing and real-time class-independent routines –common services such as context switching, run queue manipulation, and preemption class-dependent routines –priority computation and inheritance

Process Scheduling 15 SVR4 Scheduler (cont) SVR4 dispatch queues P dqactmap PP PP 1010 dispq...

Process Scheduling 16 SVR4 Scheduler (cont) SVR4 kernel defines several preemption points –places in the kernel code where all kernel data structures are in a stable state, and the kernel is about to embark on a length computation Three ranges of 160 priorities –0 ~ 59: time-sharing class –60 ~ 99: system priorities –100 ~ 159: real-time class

Process Scheduling 17 SVR4 Scheduler (cont) interface to the scheduling class real-time time-sharing system rt_classfuncs rt-init sys_classfuncs ts_classfuncs Global class table sys-init ts-init p_cid p_clfuncs p_clproc... p_cid p_clfuncs p_clproc... p_cid p_clfuncs p_clproc... p_cid p_clfuncs p_clproc... class-dependent data class-dependent data class-dependent data class-dependent data proc structures

Process Scheduling 18 SVR4 Scheduler (cont) Time-sharing class –changes process priorities dynamically –round-robin scheduling with the same priority –event driven scheduling reduces process priority each time it uses up its time slice boosts the priority of the process if it blocks on an event or resource, or if it takes a long time to use up it quantum

Process Scheduling 19 SVR4 Scheduler (cont) Real-time class –scheduled before any kernel process –fixed priority and time quantum –requires bounded dispatch latency and response time Interrupt processing nonpreemptive kernel processing context switch application code event occurs process made runnable context switch initiated process is scheduled to run process responds to event time dispatch latency response time

Process Scheduling 20 SVR4 Scheduler (cont) Analysis –allows the addition of scheduling class –time-sharing class changes priorities based on events related to that process –favor I/O-bound and interactive jobs over CPU- bound ones –code path btw preemption points is too long for time-critical applications –difficult to tune the system properly for a mixed set of jobs

Process Scheduling 21 Solaris 2.x Scheduling Enhancement Preemptive kernel –most global kernel data structures must be protected by synchronization objects –implementation of interrupts using special kernel threads Multiprocessor support –single dispatch queue for all processors

Process Scheduling 22 MP Scheduling in Solaris 2.x Initial situation P1P2P3P4P5 T1 pri 120 T2 pri 130 T3 pri 100 T4 pri 132 T5 pri 135 T6 pri 130 T7 pri 115

Process Scheduling 23 MP Scheduling in Solaris (cont) After T6 and T7 become runnable P1P2P3P4P5 T1 pri 120 T2 pri 130 T3 pri 100 T4 pri 132 T5 pri 135 about to be switched out CPU_chosen_level = 130 T6 pri 130 T7 pri 115 dispatcher queues about to be scheduled on P3

Process Scheduling 24 Priority Inversion Lower priority process holds a resource needed by a higher priority process, thereby blocking that higher priority process Solved by priority inheritance –when a high-priority thread blocks on a resource, it temporarily transfer its priority to the lower priority thread that owns the resource

Process Scheduling 25 Priority Inversion (cont) T1 pri 100 currently running holdsblocks T2 pri 130 T3 pri 110 becomes runnable (a) Initial situation (b) Without priority inheritance (c) With priority inheritance T1 pri 100 runnable holdsblocks T2 pri 130 T3 pri 110 currently running dispatcher queues T1 pri 100 runnable holdsblocks T2 pri 130 T3 pri 110 dispatcher queues currently running inh pri = 130 R R R

Process Scheduling 26 Priority Inversion (cont) Transitive priority inheritance T6 pri 100 currently running holdsblocks T5 pri 110 R1 (a) Initial situation holdsblocks T4 pri 135 R2 T7 pri 122 becomes runnable T6 pri 100 currently running holdsblocks T5 pri 110 R1 (b) Transitive priority inheritance holdsblocks T4 pri 135 R2 T7 pri 122 runnable inh pri = 135 dispatcher queues

Process Scheduling 27 Priority Inheritance Traversing the synchronization chain currently running T4 gp 100 runnable blocked threads R1 T5 gp 80 R2R3R4 T1 gp 60 ip 100 T6 gp 110 T2 gp 90 ip 100 T3 gp 70 holds owner holds wants owner holds owner gp = global priority ip = inherited priority

Process Scheduling 28 Priority Inheritance (cont) currently running T4 gp 100 blocked threads R1 T5 gp 80 ip 110 R2R3R4 T1 gp 60 ip 110 T6 gp 110 T2 gp 90 ip 100 T3 gp 70 holds owner holds owner holds owner gp = global priority ip = inherited priority

Process Scheduling 29 Priority Inheritance (cont) Limitations –is not used for semaphores and condition variables since the owner is usually indeterminate Turnstiles –reduce information maintained by kernel for hundreds of synchronization objects Turnstile pool T T T T T T active Blocked threads Synchronization objects active

Process Scheduling 30 Scheduling in Mach Schedules threads regardless of the task to which they belong Handoff scheduling –a thread can directly yield the processor to another thread w/o searching the run queue –improves the performance of the IPC calls Multiprocessor support –processor allocation can be handled by a user-lever server program –gang scheduling

Process Scheduling 31 Other Scheduling Deadline-driven scheduling Three-level scheduler –isochronous class –real-time class –general-purpose class –admission control