Traditional UNIX Scheduling Scheduling algorithm objectives Provide good response time for interactive users Ensure that low-priority background jobs do.

Slides:



Advertisements
Similar presentations
Uniprocessor Scheduling Chapter 9 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Advertisements

Operating Systems Process Scheduling (Ch 3.2, )
Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D. .
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
1 Friday, June 16, 2006 "In order to maintain secrecy, this posting will self-destruct in five seconds. Memorize it, then eat your computer." - Anonymous.
Ceng Operating Systems Chapter 2.2 : Process Scheduling Process concept  Process scheduling Interprocess communication Deadlocks Threads.
CPU Scheduling Section 2.5.
Day 25 Uniprocessor scheduling. Algorithm: Selection function Selection function – which process among ready processes to select. w – time spent in system,
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, )
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.
CS 3013 & CS 502 Summer 2006 Scheduling1 The art and science of allocating the CPU and other resources to processes.
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 Traditional OSes with Soft Real- Time Scheduling Module 3.3 For a good summary, visit:
5: CPU-Scheduling1 Jerry Breecher OPERATING SYSTEMS SCHEDULING.
1 Scheduling in Representative Operating Systems.
Chapter 9 Uniprocessor Scheduling
1 Uniprocessor Scheduling Chapter 9. 2 Aims of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Job scheduling Queue discipline.
Operating Systems Process Scheduling (Ch 4.2, )
1 Lecture 10: Uniprocessor Scheduling. 2 CPU Scheduling n The problem: scheduling the usage of a single processor among all the existing processes in.
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.
Process Scheduling in Windows XP, Linux, and UNIX By Sarah G. Levinson CSC 4320.
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.
Chapter 5: CPU Scheduling (Continuation). 5.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 2, 2005 Determining Length.
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.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 5 Operating Systems.
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 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College, Venice,
Operating System Examples - Scheduling
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.
CPU Scheduling Thomas Plagemann (with slides from Otto J. Anshus, Kai Li, Pål Halvorsen and Andrew S. Tanenbaum)
Uniprocessor Scheduling Chapter 9. Aim of Scheduling To improve: Response time: time it takes a system to react to a given input Turnaround Time (TAT)
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
Process Scheduling in Linux (Chap. 11, Understanding the Linux Kernel) J. H. Wang Sep. 26, 2008.
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
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Scheduling II: priority scheduling.
Scheuduling.
1 Unix Architecture. 2 Operating Systems Concepts 1. Process 2. Memory management 3. Information protection & security 4. Scheduling and resource management.
Uniprocessor Scheduling Chapter 9. Aim of Scheduling Assign processes to be executed by the processor or processors: –Response time –Throughput –Processor.
Chapter 9 Uniprocessor Scheduling Operating Systems: Internals and Design Principles, 6/E William Stallings Dave Bremer Otago Polytechnic, N.Z. ©2008,
Operating System Examples - Scheduling. References r er/ch10.html r bangalore.org/blug/meetings/200401/scheduler-
1 Uniprocessor Scheduling Chapter 9. 2 Aim of Scheduling Assign processes to be executed by the processor(s) Response time Throughput Processor efficiency.
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.
UNIT–II: Process Management
Uniprocessor Scheduling
Chapter 2.2 : Process Scheduling
Chapter 5: CPU Scheduling
CPU Scheduling Basic Concepts Scheduling Criteria
Chapter 6: CPU Scheduling
Operating System Concepts
Lecture 17 Syed Mansoor Sarwar
TDC 311 Process Scheduling.
Chapter 9 Uniprocessor Scheduling
CPU SCHEDULING.
CPU scheduling decisions may take place when a process:
Process Scheduling Decide which process should run and for how long
CS703 – Advanced Operating Systems
Uniprocessor Scheduling
Presentation transcript:

Traditional UNIX Scheduling Scheduling algorithm objectives Provide good response time for interactive users Ensure that low-priority background jobs do not starve Scheduling algorithm implementation Multilevel feedback using round robin within each of the priority queues 1 second preemption Priority based on process type and execution history Priorities are recomputed once per second Base priority divides all processes into fixed bands of priority levels Bands used to optimize access to block devices (e.g., disk) and to allow the OS to respond quickly to system calls

Traditional UNIX Scheduling (cont.) CPU j (i) = Measure of processor utilization by process j through interval i P j ( i ) = Priority of process j at beginning of interval i ; lower values equal higher priorities Base j =Base priority of process j nice j =User controllable adjustment factor CPU j ( i – 1) P j (i) = Base j + 2 CPU j ( i – 1) 2 CPU j (i) = + nice j

Traditional UNIX Scheduling Functions #include int getpriority (int which, id_t who); int setpriority (int which, id_t who, int prio); which - PRIO_PROCESS, PRIO_PGRP, or PRIO_USER prio - is a value in the range -20 to 20. The default priority is 0

Traditional UNIX Scheduling (cont.) Bands in decreasing order of priority Swapper Block I/O device control File manipulation Character I/O device control User processes Goals Provide the most efficient use of I/O devices Within the user process band, use the execution history to penalize processor-bound processes at the expense of I/O bound processes Example of process scheduling Processes A, B, and C are created at the same time with base priorities of 60 Clock interrupts the system 60 times a second and increments counter for running process

Traditional UNIX Scheduling (Example)

Linux Scheduling Enhances the traditional UNIX scheduling by adding two new scheduling classes for real- time processing Scheduling classes SCHED_FIFO: First-in-first-out real-time threads SCHED_RR: Round-robin real-time threads SCHED_OTHER: Other, non-real-time threads

Linux Scheduling (cont.) Scheduling for the FIFO threads is done according with the following rules An executing FIFO thread can be interrupted only when Another FIFO thread of higher priority becomes ready The executing FIFO thread becomes blocked, waiting for an event The executing FIFO thread voluntarily gives up the processor (sched_yield) When an executing FIFO thread is interrupted, it is placed in a queue associated with its priority When a FIFO thread becomes ready and it has a higher priority than the currently running thread, the running thread is pre- empted and the thread with the higher priority is executed. If several threads have the same, higher priority, the one that has been waiting the longest is assigned the processor

Linux Scheduling (cont.) Scheduling for the Round-Robin threads is similar, except for a time quota associated with each thread At the end of the time quota, the thread is suspended and a thread of equal or higher priority is assigned the processor

Linux Scheduling: FIFO vs. RR

Linux Scheduling – Using POSIX API struct sched_param scheduling_value; pthread_attr_t thread_attr; res = pthread_attr_init(&thread_attr); pthread_attr_setschedpolicy(&thread_attr,SCHED_OTHER); max_priority = sched_get_priority_max(SCHED_OTHER); min_priority = sched_get_priority_min(SCHED_OTHER); scheduling_value.sched_priority = min_priority; pthread_attr_setschedparam(&thread_attr, &scheduling_value); pthread_create(&a_thread, &thread_attr, thread_function, (void *)message);

Windows 2000 Scheduling Goal: optimize response for Single user in highly interactive environment, or Server Implementation Priority-driven preemptive scheduler with round-robin within a priority level When a thread becomes ready and has higher priority than the currently running thread, the lower priority thread is preempted Dynamic priority variation as function of current thread activity for some levels

Windows 2000 Scheduling (cont.) Real-time priorities: Real-time tasks or time-dependent functions Have precedence over other threads Variable priorities Non-real-time tasks and functions

Windows 2000 Scheduling (cont.)

Real-time priority class All threads have a fixed priority that never changes All active threads at a given priority level are in a round-robin queue Variable priority class A thread’s priority begins at some initial assigned value and then may change, up or down, during the thread’s lifetime There is a FIFO queue at each priority level, but a thread may migrate to other queues within the variable priority class The initial priority of a thread is determined by Process base priority: attribute of the process object, from 0 to 15 Thread base priority: equal to that of its process or within two levels above or below that of the process Dynamic priority Thread starts with base priority and then fluctuates within given boundaries, never falling under base priority or exceeding 15

Windows 2000 Scheduling (cont.) Variable priority class: dynamic priorities If thread is interrupted because it has used its current time quantum, executive lowers its priority: processor- bound threads move toward lower priorities If thread is interrupted to wait on an I/O event, executive raises its priority: I/O-bound threads move toward higher priorities Priority raised more for interactive waits (e.g., wait on keyboard or display) Priority raised less for other I/O (e.g., disk I/O)

Windows 2000 Scheduling (cont.) Example A process object has a base priority of 4 Each thread associated with this process can have an initial priority between 2 and 6 and dynamic priorities between 2 and 15 The thread’s priority will change based on its execution characteristics

Windows 2000 Scheduling (cont.) Real_Time_Priority_Class High_Priority_Class Normal_Priority_Class Idle_Priority_Class Modifiers Scheduler Dynamic boost Thread Priority Process Class Real Time Critical Idle 16Real Time Idle

Win32 API for Scheduling For a Process BOOL SetPriorityClass( HANDLE hProc, DWORD priClass ); DWORD GetPriorityClass( HANDLE hProc ); IDLE_PRIORITY_CLASS : 4 NORMAL_PRIORITY_CLASS : 8 HIGH_PRIORITY_CLASS : 13 REAL_TIME_PRIORTY_CLASS : 24 For a Thread BOOL SetThreadPriority( HANDLE hThread, int level ); int GetThreadPriority( HANDLE hThread ); THREAD_PRIORITY_LOWEST THREAD_PRIORITY_BELOW_NORMAL THREAD_PRIORITY_NORMAL THREAD_PRIORITY_ABOVE_NORMAL THREAD_PRIORITY_HIGHEST THREAD_PRIORITY_IDLE : 1(16 for real-time process) THREAD_PRIORITY_TIME_CRITICAL : 15 (31 for real-time process)