3. MEMORY MANAGEMENT

3.2. swapping

Memory management techniques

1. Swapping

When the process is to be executed, then that process is taken from secondary memory to stored in RAM.But RAM have limited space so we have to take out and take in the process from RAM time to time. This process is called swapping. The purpose is to make a free space for other processes. And later on, that process is swapped back to the main memory.

The situations in which swapping takes place

  1. The Round Robin algorithm is executing in which the quantum process is supposed to preempt after running for some time. In that case, that process is swapped out, and the new process is swapped in.
  2. When there is a priority assigned to each process, the process with low priority is swapped out, and the higher priority process is swapped in. After its execution, the lower priority process is again swapped in, and this process is so fast that users will not know anything about it.
  3. In the shortest time remaining first algorithm, when the next process(which arrives in the ready queue) has less burst time, then the executing process is preempted.
  4. When a process has to do I/O operations, then that process temporarily swapped out.

It is further divided into two types:

  1. Swap-in: Swap-in means removing a program from the hard disk and putting it back in the RAM. 
  2. Swap-out: Swap-out means removing a program from the RAM and putting it into the hard disk.