Definition of multiprogramming
The process of sharing CPU time with multiple programs or jobs is called multiprogramming. Multiprogramming is based on content switching. In context switching, one job run until I/O interrupt occurs. When I/O interrupt occurs then CPU switch to another job. There may also occur other types of interrupts like event interrupt, memory interrupt, hardware interrupt etc. Interrupts are just like alert actions that notify CPU to stop performing a task and switch to another task. The benefit of context switching is that operating system (OS) work efficiently and every program run smoothly on the computer.
In memory, different partitions are made for low priority and high priority programs. When an interrupt occurs for high priority program then that program goes to the waitlist. After interrupt action is completed i.e. I/O is done then high priority program goes back to the running stage. There are different partitions made in main memory like fixed partition and variable partition. For fixed partition, only a fixed number of programs reside and processed in main memory and given same space in memory. Other programs have to wait until any program completes. In variable partition, programs are given variable memory size depending upon the size of the program and when more programs come into memory partition becomes bigger until some specific size. For a fixed number of tasks, the fixed partition is best to be used.
Definition of multitasking
In multitasking, each task is given a specific amount of time. For example, while using a computer you can listen to mp3, work on excel and browse the internet. You perform all these tasks at the same time. Multitasking is based on time sharing. Operating system (OS) handles all the jobs (tasks) by giving some time (nanoseconds) to each job. All jobs reside in main memory. OS share time between processes very fast. A normal user cannot notice any time gap in the performance of tasks in the computer.
Multiprogramming vs multitasking
In multiprogramming context switching is used and in multitasking, time-sharing is used. Multiprogramming is a little extension from multitasking. Multiprogramming is used for a single processor. All programs reside in main memory and handled by the single processor. Multiprogramming and multitasking are sometimes used for the same purpose but there is the difference between them as I explained. Multitasking is a new term used in a computer. It is mostly used in modern games.
Examples of multiprogramming
- Multiple programs running parallel in main memory
- Making fixed and variable partition of programs in memory
Examples of multitasking
- Performing multiple tasks in iPad
- Performing multiple tasks in iPhone
- Multitasking in games
- Using MS word, chrome, listening mp3 at the same time
- Multitasking in games