Multitasking / Time-Sharing in Operating System



Multitasking operating systems are modern and advanced versions of multiprogramming operating systems. It supports the execution of multiple tasks simultaneously by rapidly switching between them. Due to this, the multitasking operating system is also known as a time-sharing operating system.

Read this chapter to understand more about multitasking operating systems, its working, advantages, disadvantages, and examples.

What is Multitasking?

In the context of operating systems, multitasking refers to the ability of an operating system to execute multiple tasks or processes at the same time. This is achieved by rapidly switching processes in and out of the CPU, such that each process gets a small time slice to execute. This create an illusion of simultaneous execution of multiple tasks. Even though only one CPU core is present, it can handle multiple tasks by switching between them quickly.

The operating system that supports multitasking is called a multitasking operating system. Most of the modern operating systems like Windows, Linux, and macOS are multitasking operating systems.

Working of Multitasking Operating System

The animation below shows the working of a multitasking operating system −

Working of Multitasking Operating System

In the above animation,

Step 1 − Multiple tasks (Task A, Task B, Task C, and Task D) are loaded into the main memory.

Step 2 − The operating system allocates a small time slice to Task A, and it gets executed for that duration.

Step 3 − After Task A's time slice is over, the operating system switches to Task B and allocates it a time slice.

Step 4 − This process continues for all tasks. Once all tasks have had their turn, the operating system goes back to Task A and repeats the cycle.

Examples of Multitasking Operating System

Most of the modern operating systems support multitasking. Some popular examples of multitasking operating systems are −

  • Windows − All versions of Microsoft Windows, like Windows 10, Windows 11, and Windows Server editions, support multitasking.
  • Linux − All the distributions of Linux, such as Ubuntu, Fedora, and CentOS, are multitasking operating systems.
  • macOS − Apple's macOS is a multitasking operating system used in Mac computers.
  • Unix − Unix and its variants, such as AIX, HP-UX, and Solaris, are multitasking operating systems used in servers and workstations.
  • Android − Android is a multitasking operating system used in smartphones and tablets.
  • iOS − Apple's iOS is a multitasking operating system used in iPhones and iPads.

Advantages of Multitasking Operating System

Some of the advantages of multitasking operating systems are −

  • High Responsiveness − Multitasking operating systems create an illusion of simultaneous execution of multiple tasks with a single CPU core. This makes the system more responsive to user inputs.
  • Maximum CPU Utilization − By rapidly switching between tasks, multitasking operating systems ensure that the CPU is always busy.
  • Better User Experience − Multitasking allows users to run multiple applications simultaneously, enhancing productivity and user experience.

Disadvantages of Multitasking Operating System

Some of the disadvantages of multitasking operating systems are −

  • Complexity − Multitasking operating systems requires complex algorithms for process scheduling, memory management, and context switching.
  • Overhead − The frequent context switching between tasks introduces overhead, which can reduce overall system performance.
  • Thrashing − If too many tasks are running simultaneously, the system may spend more time switching between tasks than executing them, this is known as thrashing.

Multitasking vs Multiprogramming Operating Systems

Multiprogramming is a method of running multiple programs on a single processor in such a way that the CPU is always busy. Here are some key differences between multiprogramming and multitasking operating systems −

Aspect Multitasking OS Multiprogramming OS
Definition In multitasking, multiple tasks or processes are executed simultaneously by rapidly switching between them. In multiprogramming, multiple programs are kept in memory, and the CPU is allocated to one program at a time.
Focus Multitasking focuses sharing CPU time among multiple tasks to provide an illusion of simultaneous execution. Multiprogramming focuses on maximizing CPU utilization by keeping it busy with multiple jobs.
Context Switching Context switching in multitasking is more frequent Context switching is less frequent, happens only in the event of I/O operations or job completion.
Number of Cores/CPUs Designed for multi-core or multi-CPU systems. Works on single-core or single-CPU systems. But can be implemented on multi-core systems as well.
Use Case Multitasking is commonly used in modern operating systems like Windows, Linux, and macOS. Multiprogramming is primarily used in batch processing systems.

Conclusion

Most of the modern operating systems are multitasking operating systems, because they provide better responsiveness, maximum CPU utilization, and better user experience. However, the main drawbacks of multitasking operating systems are their complexity, overhead due to context switching. Also if the system is not managed properly and it have too many tasks running simultaneously, then it may lead to thrashing.

Advertisements