Multi Programming
Multi Programming
Types of multiprogramming
Multiprogramming is implemented in one of two ways: cooperative
multiprogramming or preemptive multiprogramming.
Cooperative multiprogramming is the older of the two models and is seldom used
today. With cooperative multiprogramming, context switching is initiated by the
programs themselves rather than the OS. Processor resources are reassigned only
when a program releases control of those resources. The operating system has no
choice but to execute a program with the expectation, but not the certainty, that the
program will eventually return control to the OS.
The problem with this approach is that a program can monopolize CPU resources for
an inordinate amount of time, keeping other programs waiting. Even worse, a buggy
or malicious program might launch an infinite loop and never give up control of the
CPU, resulting in a locked system or system crash. Not only does this disrupt user
and application workflows, but it can be difficult to debug because it might not be
obvious which of several programs is at fault.
With preemptive multiprogramming, the OS has complete control over context
switching. It allocates CPU resources based on queued programs and their I/O
operations, while limiting the time each program can run. So, if there is a problem
with one of the programs, it cannot interfere with operations indefinitely. Today, most
computers use preemptive multiprogramming.