Multitasking - aryanjoshi0823/5143-Operating-System GitHub Wiki

Multitasking OS is a logical extension of multiprogramming, enabling several programs to run simultaneously. It supports concurrent execution of tasks by allocating memory and processing time efficiently to each process.


Components of a Multitasking Operating System

  1. Process Creation: New processes are created using system calls like fork(). This results in two processes running concurrently: a parent process and a child process.
  2. Process ID Management: Functions like getpid() retrieve the process ID of the current process, while getppid() retrieves the parent process's ID.
  3. Conditional Execution: The OS differentiates between parent and child processes using conditions to execute the appropriate code.

Types of Multitasking OS

Preemptive

  • The OS allocates a fixed amount of CPU time to each task, switching tasks once their time expires.
  • Examples: Unix, Windows NT/95, macOS X.

Cooperative

  • Tasks voluntarily relinquish control to allow other tasks to run.
  • Examples: Early versions of Windows and MacOS.