Multitasking operating system is a software that offers interleave execution of more than one process. It is capable of executing several processes concurrently and therefore giving an illusion of parallelism in the view of user abstraction. Multitasking operating systems come in two flavors: cooperative multitasking and preemptive multitasking.

In cooperative multitasking, a process does not stop running until it is voluntary to do so. As the result, process in a cooperative multitasking system can dominates processor time. Conversely, in preemptive multitasking, a running process is suspended involuntarily so that next process can be run.

Being one of the multitasking operating system, Linux kernel implements preemptive multitasking, where the time that a process runs before it is switched is usually predetermined. The predetermined time, called as timeslice of the process, gives each runnable process a slice of the processor’s time and by managing the timeslice, it enables scheduler to make global scheduling decisions for the system. It also prevents any one process from monopolizing the processor.

There are two main challenges on the implementation of multitasking in Linux kernel:

  • The kernel is responsible for the technical details of task switching, where each individual process must be given the illusion that the CPU is always available. This is accomplished by storing process state before task is switched, and the exact saved state is restored when the process is reactivated.
  • The kernel must also decide how processor time is shared between the existing processes, i.e. important processes are given a slice of time, less important processes a smaller slice. The linux scheduler is responsible for deciding the duration of each process.