Nepedia
Back to Discover
Advanced Reader
💻

Scheduling (computing)

technology Maturity 7-9 war conflict Next article →

This article covers sensitive topics: war_conflict. Parents can manage visibility in Parental Controls.

In computing, scheduling is the essential process of assigning resources to perform specific tasks. These resources can include processors, network links, or expansion cards. The tasks being managed are often threads, processes, or data flows. This activity is managed by a specialized mechanism known as a scheduler. Scheduling is fundamental to computation and is an intrinsic part of a computer's execution model. It is the concept that makes multitasking possible even on a system with a single central processing unit (CPU).

Thread pool
Thread pool

A scheduler typically aims to achieve several specific goals. One primary goal is maximizing throughput, which is the total amount of work completed per time unit. Another goal is minimizing wait time, which is the duration from when work becomes ready until it begins execution. Schedulers also work to minimize latency or response time. In interactive systems, response time is the interval between a task becoming ready and the system providing the first output to the user. Finally, schedulers aim for fairness, which means providing equal or appropriate CPU time to each process based on its priority and workload. In practice, these goals often conflict, such as the tension between throughput and latency. Therefore, a scheduler must implement a suitable compromise based on user needs.

Operating systems utilize up to three distinct types of schedulers to manage these tasks. The first is the long-term scheduler, also called the admission scheduler. This module decides which jobs or processes are admitted to the ready queue in main memory. It dictates the degree of concurrency and manages the split between different types of processes. Specifically, it balances I/O-bound processes, which spend more time on input/output, and CPU-bound processes, which spend more time on computations. A good mix is vital for performance. If all processes are I/O-bound, the short-term scheduler will have little to do. If all are CPU-bound, hardware devices may go unused.

Simplified Structure of the Linux Kernel
Simplified Structure of the Linux Kernel

The medium-term scheduler provides another layer of management by handling memory. It temporarily removes processes from main memory and places them in secondary memory, such as a hard disk drive. This process is commonly referred to as swapping out or swapping in. The scheduler may swap out a process if it has low priority, is not active, or uses too much memory. This frees up main memory for other processes. In some modern systems, the medium-term scheduler also performs long-term scheduling tasks. It can use a method called demand paging, where segments of a binary are swapped in only when they are required.

The short-term scheduler, or CPU scheduler, makes decisions much more frequently than the other types. It selects which in-memory process will be allocated the CPU after a clock interrupt, an I/O interrupt, or a system call. This scheduler can be preemptive, meaning it can forcibly remove a process from the CPU to start a new one. If it cannot force a process off the CPU, it is known as a cooperative scheduler. To execute these decisions, the system uses a module called the dispatcher. The dispatcher performs context switches, which involve saving the state of the old process and loading the state of the new one. The time required for this switch is known as dispatch latency.

Thread pool
Thread pool

To distribute resources, schedulers follow specific rules called scheduling disciplines or algorithms. One of the simplest methods is First-In, First-Out (FIFO), also called First-Come, First-Served (FCFS). This algorithm queues processes in the exact order they arrive. While it has minimal overhead, it can suffer from the convoy effect, where long processes cause short processes to wait a long time. Other more complex algorithms include priority scheduling. For example, Earliest Deadline First (EDF) is a dynamic algorithm used in real-time operating systems. It searches for the process closest to its deadline to determine the next task for execution.

Scheduling is critical in various specialized environments. In real-time environments, such as industrial robotics, schedulers must ensure processes meet strict deadlines to keep the system stable. In computer networks, scheduling algorithms manage packet traffic in routers. Advanced wireless networks, like LTE, use channel-dependent scheduling to improve efficiency. These systems can assign resources to users who can best utilize them based on current conditions. Whether managing a single laptop or a massive supercomputer, scheduling ensures that computing resources are used effectively and fairly.

733 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (2)
File:Thread pool.svg
Thread pool.svg
File:Simplified Structure of the Linux Kernel.svg
Simplified Structure of the Linux Kernel.svg
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.