Question-1 Compare multiprogramming with fixed partition & multiprogramming with variable partition with diagram. OR Explain swapping in memory management.
- In practice total amount of memory needed by all the processes is often much more than the available memory.
- Swapping is used to deal with memory overhead.
- Swapping consists of bringing in each process in its entirety, running it for a while, then putting it back on the disk.
- The event of copying process from hard disk to main memory is called as Swappedin.
- The event of copying process from main memory to hard disk is called as Swappedout.
- When swapping creates multiple holes in memory, it is possible to combine them all into one big one by moving all the processes downward as far as possible. This technique is called as memory compaction.
- Two ways to implement Swapping System
- Multiprogramming with Fixed partitions.
- Multiprogramming with dynamic partitions.
Multiprogramming with Fixed partitions
- This method allows multiple processes to execute simultaneously.
- Here memory is divided into fixed sized partitions. Size can be equal or unequal for different partitions.
- Generally unequal partitions are used for better utilizations.
- Each partition can accommodate exactly one process, means only single process can be placed in one partition.
- The partition boundaries are not movable.
- Whenever any program needs to be loaded in memory, a free partition big enough to hold the program is found. This partition will be allocated to that program or process.
- If there is no free partition available of required size, then the process needs to wait. Such process will be put in a queue.
- There are two ways to maintain queue
- Using multiple Input Queues.
- Using single Input Queue.
- The disadvantage of sorting the incoming jobs into separate queues becomes apparent when the queue for a large partition is empty but the queue for a small partition is full, as is the case for partitions 1 and 3 in Fig. (a).
- Here small jobs have to wait to get into memory, even though plenty of memory is free. An alternative organization is to maintain a single queue as in Fig. (b). Whenever a partition becomes free, the job closest to the front of the queue that fits in it could be loaded into the empty partition and run.
Figure (a) Fixed memory partitions with separate input queues for each partition. (b) Fixed memory partitions with a single input queue.
Multiprogramming with dynamic partitions
- This method also allows multiple processes to execute simultaneously.
- Here, memory is shared among operating system and various simultaneously running processes.
- Memory is not divided into any fixed partitions. Also the number of partitions is not fixed. Process is allocated exactly as much memory as it requires.
- Initially, the entire available memory is treated as a single free partition.
- Whenever any process enters in a system, a chunk of free memory big enough to fit the process is found and allocated. The remaining unoccupied space is treated as another free partition.
- If enough free memory is not available to fit the process, process needs to wait until required memory becomes available.
- Whenever any process gets terminate, it releases the space occupied. If the released free space is contiguous to another free partition, both the free partitions are merged together in to single free partition.
- Better utilization of memory than fixed sized size partition.
- This method suffers from External fragmentation.
Figure Memory allocation changes as processes come into memory and leave it. The shaded regions are unused memory.
You may be interested in:
Operating System Short Descriptive Questions and Answers