![]() |
VOOZH | about |
| Feature | Multiprogramming | Multitasking | Multithreading | Multiprocessing |
| Definition | Running multiple programs on a single CPU | Running multiple tasks (applications) on a single CPU | Running multiple threads within a single task (application) | Running multiple processes on multiple CPUs (or cores) |
| Resource Sharing | Resources (CPU, memory) are shared among programs | Resources (CPU, memory) are shared among tasks | Resources (CPU, memory) are shared among threads | Each process has its own set of resources (CPU, memory) |
| Scheduling | Uses round-robin or priority-based scheduling to allocate CPU time to programs | Uses priority-based or time-slicing scheduling to allocate CPU time to tasks | Uses priority-based or time-slicing scheduling to allocate CPU time to threads | Each process can have its own scheduling algorithm |
| Memory Management | Each program has its own memory space | Each task has its own memory space | Threads share memory space within a task | Each process has its own memory space |
| Context Switching | Requires a context switch to switch between programs | Requires a context switch to switch between tasks | Requires a context switch to switch between threads | Requires a context switch to switch between processes |
| Inter-Process Communication (IPC) | Uses message passing or shared memory for IPC | Uses message passing or shared memory for IPC | Uses thread synchronization mechanisms (e.g., locks, semaphores) for IPC | Uses inter-process communication mechanisms (e.g., pipes, sockets) for IPC |
In a computer system, many jobs wait for CPU execution. Since memory cannot hold all jobs at once, they are kept in a job pool. In a Multiprogramming Operating System, when one job goes for an I/O operation, the operating system assigns the CPU to another job. This keeps the CPU busy and improves system efficiency.
In the image below, program A runs for some time and then goes to waiting state. In the mean time program B begins its execution. So the CPU does not waste its resources and gives program B an opportunity to run.
In a uni-processor system, only one process executes at a time. Multiprocessing is the use of two or more CPUs (processors) within a single Computer system. This allows multiple processes to run simultaneously, improving system speed and performance. The processors share resources such as memory, clock, and peripheral devices.
Multitasking refers to the ability of an operating system to run multiple tasks at the same time. It is an extension of Multiprogramming Operating System. In multitasking, the CPU shares its time among different tasks using time sharing and context switching. Each process is given a small time slice (quantum), and after that time the CPU switches to another process. Because this switching happens very quickly, it appears that many programs are running simultaneously, even though only one process executes at a time on a single CPU.
Key Points:
In a more general sense, multitasking refers to having multiple programs, processes, tasks, threads running at the same time. This term is used in modern operating systems when multiple tasks share a common processing resource (e.g., CPU and Memory).
A thread is a basic unit of CPU utilization. Multithreading is an execution model that allows a single process to have multiple threads running concurrently within the same process. Each thread performs a specific task while sharing the same resources of the process. For example, in VLC media player, one thread may handle opening the player, another may play a song, and another may manage the playlist. Multithreading allows a process to handle multiple tasks or user requests efficiently without running multiple copies of the program.
The image below completely describes the VLC player example:
Advantages of Multi threading -