Scheduling (computing)
From Wikipedia, the free encyclopedia
| This article may require cleanup to meet Wikipedia's quality standards. Please improve this article if you can. (April 2008) |
Scheduling is a key concept in computer multitasking and multiprocessing operating system design, and in real-time operating system design. It refers to the way processes are assigned priorities in a priority queue. This assignment is carried out by software known as a scheduler.
In real-time environments, such as mobile devices for automatic control in industry (for example robotics), the scheduler also must ensure that processes can meet deadlines; this is crucial for keeping the system stable. Scheduled tasks are sent to mobile devices and managed through an administrative back end.
Contents |
[edit] Types of operating system schedulers
Operating systems may feature up to 3 distinct types of schedulers: a long-term scheduler (also known as an admission scheduler or high-level), a mid-term or medium-term scheduler and a short-term scheduler (also known as a dispatcher). The names suggest the relative frequency with which these functions are performed.
[edit] Long-term Scheduler
The long-term, or admission, scheduler decides which jobs or processes are to be admitted to the ready queue; that is, when an attempt is made to execute a program, its admission to the set of currently executing processes is either authorized or delayed by the long-term scheduler. Thus, this scheduler dictates what processes are to run on a system and the degree of concurrency to be supported at any one time - ie: whether a high or low amount of processes are to be executed concurrently, and how the split between IO intensive and CPU intensive processes is to be handled. Typically for a desktop computer, there is no long-term scheduler as such, and processes are admitted to the system automatically. However this type of scheduling is very important for a real time system, as the system's ability to meet process deadlines may be compromised by the slowdowns and contention resulting from the admission of more processes than the system can safely handle. [Stallings, 399].
[edit] Mid-term Scheduler
The mid-term scheduler, present in all systems with virtual memory, temporarily removes processes from main memory and places them on secondary memory (such as a disk drive) or vice versa. This is commonly referred to as "swapping out" or "swapping in" (also incorrectly as "paging out" or "paging in"). The mid-term scheduler may decide to swap out a process which has not been active for some time, or a process which has a low priority, or a process which is page faulting frequently, or a process which is taking up a large amount of memory in order to free up main memory for other processes, swapping the process back in later when more memory is available, or when the process has been unblocked and is no longer waiting for a resource. [Stallings, 396] [Stallings, 370]
In many systems today (those that support mapping virtual address space to secondary storage other than the swap file), the mid-term scheduler may actually perform the role of the long-term scheduler, by treating binaries as "swapped out processes" upon their execution. In this way, when a segment of the binary is required it can be swapped in on demand, or "lazy loaded". [Stallings, 394]
[edit] Short-term Scheduler
The short-term scheduler (also known as the dispatcher) decides which of the ready, in-memory processes are to be executed (allocated a CPU) next following a clock interrupt, an IO interrupt, an operating system call or another form of signal. Thus the short-term scheduler makes scheduling decisions much more frequently than the long-term or mid-term schedulers - a scheduling decision will at a minimum have to be made after every time slice, and these are very short. This scheduler can be preemptive, implying that it is capable of forcibly removing processes from a CPU when it decides to allocate that CPU to another process, or non-preemptive, in which case the scheduler is unable to "force" processes off the CPU. [Stallings, 396].
[edit] Scheduling disciplines
Scheduling disciplines are algorithms used for distributing resources among parties which simultaneously and asynchronously request them. Scheduling disciplines are used in routers (to handle packet traffic) as well as in operating systems (to share CPU time among threads and processes).
The main purposes of scheduling algorithms are to minimize resource starvation and to ensure fairness amongst the parties utilizing the resources.
[edit] Common scheduling disciplines
The following is a list of common scheduling practices and disciplines:
- Borrowed-Virtual-Time Scheduling (BVT)
- Completely Fair Scheduler (CFS)
- Critical Path Method of Scheduling
- Deadline-monotonic scheduling (DMS)
- Deficit round robin (DRR)
- Dominant Sequence Clustering (DSC)
- Earliest deadline first scheduling (EDF)
- Elastic Round Robin
- Fair-share scheduling
- First In, First Out (FIFO), also known as First Come First Served (FCFS)
- Gang scheduling
- Genetic Anticipatory
- Highest response ratio next (HRRN)
- Interval scheduling
- Last In, First Out (LIFO)
- Job Shop Scheduling (see Job shops)
- Least-connection scheduling
- Least slack time scheduling (LST)
- List scheduling
- Lottery Scheduling
- Multilevel queue
- Multilevel Feedback Queue
- Never queue scheduling
- O(1) scheduler
- Proportional Share Scheduling
- Rate-monotonic scheduling (RMS)
- Round-robin scheduling (RR)
- Shortest expected delay scheduling
- Shortest job next (SJN)
- Shortest time remaining (STR)
- Staircase Deadline scheduler (SD) [1]
- "Take" Scheduling
- Two-level scheduling
- Weighted fair queuing (WFQ)
- Weighted least-connection scheduling
- Weighted round robin (WRR)
- Group Ratio Round-Robin: O(1) [2]
[edit] Operating system scheduler implementations
Different computer operating systems implement different scheduling schemes. Very early MS-DOS and Microsoft Windows systems were non-multitasking, and as such did not feature a scheduler. Windows 3.1 and Mac OS 9 (not Mac OS X) and prior based operating systems used a simple non-preemptive scheduler which requires programmers to instruct their processes to "yield" (give up the CPU) in order for other processes to gain some CPU time. This provided primitive support for multitasking, but did not provide more advanced scheduling options.
Windows NT-based operating systems use a multilevel feedback queue. 32 priority levels are defined, 0 through to 31, with priorities 0 through 15 being "normal" priorities and priorities 16 through 31 being soft realtime priorities, requiring privileges to assign. Users can select 5 of these priorities to assign to a running application from the Task Manager application, or through thread management APIs. The kernel may change the priority level of a thread depending on its I/O and CPU usage and whether it is interactive (i.e. accepts and responds to input from humans), raising the priority of interactive and I/O bounded processes and lowering that of CPU bound processes, to increase the responsiveness of interactive applications.[1] The scheduler was modified in Windows Vista to use the cycle counter register of modern processors to keep track of exactly how many CPU cycles a thread has executed, rather than just using an interval-timer interrupt routine.[2]
Early Unix implementations used a scheduler with multilevel feedback queues with round robin selections within each Feedback Queue. In this system, processes begin in a high priority queue (giving a quick response time to new processes, such as those involved in a single mouse movement or keystroke), and as they spend more time within the system, they are preempted multiple times and placed in lower priority queues. Unfortunately under this system older processes may be starved of CPU time by a continual influx of new processes, although if a system is unable to deal with new processes faster than they arrive, starvation is inevitable anyway. Process priorities could be explicitly set under Unix to one of 40 values, although most modern Unix systems have a higher range of priorities available (Solaris has 160). Instead of the Windows NT 4.0 solution to low priority process starvation (bumping a process to the front of the round robin queue should it be starving), early Unix systems used a more subtle aging system, to slowly increase the priority of a starving process until it was executed, whereupon its priority would be reset to whatever it was before it started starving.
The Linux kernel had been using an O(1) scheduler until 2.6.23, at which point it is switching over to the Completely Fair Scheduler.
[edit] References
- Blazewicz, J., Ecker, K.H., Pesch, E., Schmidt, G. und J. Weglarz, Scheduling Computer and Manufacturing Processes, Berlin (Springer) 2001, ISBN 3-540-41931-4
- Stallings, William (2004). Operating Systems Internals and Design Principles (fifth international edition). Prentice Hall. ISBN 0-13-147954-7.
- Stallings, William (2004). Operating Systems Internals and Design Principles (fourth edition). Prentice Hall. ISBN 0-13-031999-6.
- Information on the Linux 2.6 scheduler
- Information on the Windows NT scheduler
- Information on the Windows NT and Unix schedulers
[edit] See also
- Scheduling algorithm
- Process (computing)
- Process states
- Automated planning and scheduling
- Cyclic executive
- Dynamic priority scheduling
[edit] Further reading
- Brief discussion of Job Scheduling algorithms
- Understanding the Linux Kernel: Chapter 10 Process Scheduling
- Kerneltrap: Linux kernel scheduler articles
|
|||||||||||||||||

