Skip to content
Search

Multitasking

lastmod 2020-03-03created 2015-03-074 edits

In computer science, multitasking refers to multiple tasks (or processes, hereafter tasks) sharing common resources such as a central processing unit (hereafter CPU). Strictly speaking, a personal computer with a single CPU can perform only one task at any given moment. Multitasking therefore uses a method called scheduling to give the computer user an environment in which computation appears to happen in parallel. Scheduling divides CPU time according to certain criteria and distributes it so that each task can use it. While a task uses the CPU during its allotted time, the other tasks wait for their turn. When the allotted time ends, reassigning the CPU the task was using so that another task can use it is called a context switch; if context switches happen often enough in scheduling, the computer user perceives computation as happening in parallel.

Multitasking is also useful on computers with multiple CPUs (i.e., multiprocessors): with multitasking, more tasks than the number of installed CPUs can be run at the same time.

In general, an operating system adopts one of the scheduling methods listed below.

  • In a multiprogramming system, the currently running task continues until it has to wait for some external event or until the computer's scheduler forcibly stops the running task. Multiprogram systems were designed to maximize CPU utilization.
  • In a time-sharing system, the currently running task must give up the central processing unit either on its own or for an external reason such as a hardware interrupt. Time-sharing systems allow multiple programs to run almost simultaneously. The expression "time-sharing" was used to refer to computers such as IBM's TSO and CP/CMS, which could be shared by users at terminals.
  • In a real-time system, when an external event occurs, a number of waiting tasks are guaranteed to be able to occupy the CPU. Real-time systems are used to control mechanical devices such as industrial robots that must be handled within a time limit.

The term time-sharing, which used to describe several people sharing the same system, has been replaced by the term multitasking due to the development of personal computers and workstations, and is now rarely used except in special cases.

Multitasking methods

Multitasking operating systems use the following methods.

Cooperative Multitasking

Threads courteously yield time to each other. Even if a particular thread uses a lot of CPU time, the other threads quietly wait. Other threads cannot run until the thread holding the CPU explicitly yields.

With this approach, if one thread grabs the CPU and does not let go, a serious problem occurs in the system. It is therefore not used in typical environments today.

Preemptive Multitasking

Preemptive scheduling means forcibly taking the CPU back from the currently running process in a time-sharing system when its time slice is used up, or when, at an interrupt or the end of a system call, it is found that a higher-priority process has arisen.

It improves the stability of the whole system. A thread being forcibly stopped like this so that another thread runs is called Preemption.

See also

Favorite site

author Zer0 sitemap