Nepedia
Back to Discover
Advanced Reader
💻

Computer multitasking

technology Maturity 9-11 Next article →

Multitasking is the concurrent execution of multiple tasks, often called processes, over a specific period. In a multitasking system, new tasks can interrupt existing ones before they finish. Instead of waiting for one job to end, the computer executes segments of many tasks in an interleaved manner. This allows the system to share common processing resources, such as the central processing unit (CPU) and main memory. It is important to note that multitasking does not always require parallel execution at the exact same instant. Instead, it allows more than one task to advance over a given period of time.

Fedora Linux multitasking
Fedora Linux multitasking

To manage these tasks, the computer performs a process known as a context switch. This mechanism automatically interrupts a running program to save its current state. The system preserves partial results, memory contents, and computer register contents. Once the state is saved, the computer loads the saved state of a different program and transfers control to it. This allows the CPU to remain productive even when one program is waiting for an external event. For example, if a program is waiting for user input or an input/output transfer with a peripheral, the CPU can switch to another task.

Microsoft Windows 1.01 multitasking
Microsoft Windows 1.01 multitasking

There are two primary methods for managing these interruptions: cooperative and preemptive multitasking. In cooperative multitasking, the running program is coded to signal the supervisory software when it can be interrupted. This method was used by classic Mac OS and early versions of Microsoft Windows. However, if a poorly designed program refuses to give up control, it can cause the entire system to hang. In contrast, preemptive multitasking allows the system to interrupt programs at fixed time intervals. This ensures every process receives a regular "slice" of operating time. Preemptive multitasking is a core feature of modern Unix-like operating systems, such as Linux, and modern versions of Windows.

Multitasking has deep roots in computing history, beginning with the concept of multiprogramming. In the early days, CPU time was very expensive and peripheral devices were quite slow. Multiprogramming allowed multiple programs to be loaded into memory so the CPU could switch between them swiftly. The Bull Gamma 60, designed in 1957 and released in 1960, was the first computer built with multiprogramming in mind. Its architecture used a Program Distributor to feed up to twenty-five autonomous processing units. Another significant early machine was the LEO III, which was first released in 1961.

Kubuntu 21.04 (KDE Plasma 5) - Virtual Desktops
Kubuntu 21.04 (KDE Plasma 5) - Virtual Desktops

As technology progressed, preemptive multitasking became more widely available. It was implemented in the PDP-6 Monitor and Multics in 1964, and in Unix in 1969. For home users, Microware's OS-9 was one of the earliest preemptive systems available. The Commodore Amiga, released in 1985, offered a combination of multitasking and multimedia capabilities. Microsoft later made preemptive multitasking a core feature of its flagship systems, starting with Windows NT 3.1 and Windows 95. Today, 64-bit editions of Windows provide preemptive multitasking for all supported applications.

Microsoft Windows 1.01 multitasking
Microsoft Windows 1.01 multitasking

Modern systems also utilize threads to increase efficiency. A thread is a lightweight process that runs within the same memory context as its parent process. Because threads share the same memory space and resources, such as open files, they can exchange data very efficiently. Some operating systems also provide "fibers," which are a variant of threads that are scheduled cooperatively. Beyond standard computing, multitasking is vital for real-time systems. These systems, which might control industrial robots, use a hierarchical interrupt system. This ensures that critical tasks, like machine movement, receive priority over less urgent tasks like user interface updates.

To keep these multiple tasks safe, the system must use memory protection. This is the practice of strictly managing access to system resources to ensure stability and security. The operating system kernel and a hardware component called a Memory Management Unit (MMU) work together to manage this. The MMU ensures that a process cannot read or write to memory locations outside its own assigned address space. If a process attempts to access unauthorized memory, the MMU denies the request and signals the kernel. This often results in the process being terminated and an error like a "segmentation fault" being displayed.

Fedora Linux multitasking
Fedora Linux multitasking

Finally, multitasking is often paired with memory swapping to manage limited resources. While the two techniques are unrelated, they are frequently used together to allow more tasks to be loaded. Memory swapping uses a swap file or partition to provide more memory than is physically available in the computer. The operating system keeps portions of the primary memory in secondary storage to free up space. This allows a multitasking system to continue functioning even when the total memory required by all active processes exceeds the physical hardware capacity.

778 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (3)
File:Fedora Linux multitasking.png
Fedora Linux multitasking.png
File:Microsoft_Windows_1.01_multitasking.png
Microsoft_Windows_1.01_multitasking.png
File:Kubuntu_21.04_(KDE_Plasma_5)_-_Virtual_Desktops.png
Kubuntu_21.04_(KDE_Plasma_5)_-_Virtual_Des...
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.