You are on page 1of 2

OS Assignment 3

1. Discuss the Swapping of two processes using a disk as a backing store.

ANS. Swapping:

A process must be in the main memory before it starts execution. So, a process
that is ready for execution is brought in the main memory. Now, if a running the
process gets blocked. The memory manager temporarily swaps out that blocked
process on to the disk. This makes the space for another process in the main
memory. So, the memory manager swaps in the process ready for execution, in
the main memory, from the disk. The swapped out process is also brought back
into the main memory when it again gets ready for execution.

Swapping of the processes also depends on the priority-based pre-emptive


scheduling. Whenever a process with higher priority arrives the memory
manager swaps out the process with the lowest priority to the disk and swaps in
the process with the highest priority in the main memory for execution. When
the highest priority process is finished, the lower priority process is swapped
back in memory and continues to execute. This Variant of swapping is termed
as roll-out, roll-in or swap-out swap-in.
2. Explain the role of First fit, Best fit and worst fit techniques for efficient
memory management.

ANS. Contiguous Memory Allocation Techniques

1. First Fit

In the first fit approach is to allocate the first free partition or hole large enough
which can accommodate the process. It finishes after finding the first suitable
free partition.

Advantage: It is fast in processing.

Disadvantage : It wastes a lot of memory

2. Best Fit

The best fit deals with allocating the smallest free partition which meets the
requirement of the requesting process. This algorithm first searches the entire
list of free partitions and considers the smallest hole that is adequate. It then
tries to find a hole which is close to actual process size needed.

Advantage: Memory Efficient.

Disadvantage: It is a Slow Process.

3. Worst fit

In worst fit approach is to locate largest available free portion so that the portion
left will be big enough to be useful. It is the reverse of best fit.

Advantage:

Since this process chooses the largest hole/partition, therefore there will be large
internal fragmentation. Now, this internal fragmentation will be quite big so that
other small processes can also be placed in that leftover partition.

Disadvantage:

It is a slow process.

You might also like