Swapping Concept in Operating System:


Definition and Explanation:

A process cannot be executed in the CPU unless it is completely or partly in memory. A process not executing in CPU (for example, in the ready queue) can be completely swapped out of memory to a backing store (usually a high-speed disk). It can then be swapped in to memory when it needs to be executed.


If compile-time or load-time binding is used, a process must be swapped back in to the exact memory locations it was swapped out of. If execution-time binding is used, a process can be swapped in to a different memory location.


The swapping is done by swapper. If dispatcher tries to load a process into CPU to discover that it is not currently in memory, it calls the swapper to swap the process back in to memory. The dispatcher, the swapper or the loader must handle the policy questions of where to swap in a process and which processes to swap out when necessary.


The major part of the swap time is the transfer time. When choosing a process to swap out, we would prefer to swap out as small a process as possible. It would be nice if we do not have to swap out the entire process.


Swapping is complicated by I/O. Suppose a process has pending I/O requests and the I/O requests are completed by reading from or writing to memory locations inside the process. The process may use memory from some other process.


There are two solutions:



  • Never swap a process with pending I/O
  • Have all I/O requests read from or write to operating system buffers that are never swapped out

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Blog Archive

Powered by Blogger.

- Copyright © 2013 Taqi Shah Blogspot -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -