swapping

                                                                 SWAPPING

  Swapping is a memory management scheme in which any process can be temporarily swapped from main memory to secondary memory so that the main memory can be made available for other processes.

Backing store - fast disk large enough to
accommodate copies of all memory images for all
users ; must provide direct access to these memory
images
Roll out , roll in - swapping variant used for priority
based scheduling algorithms ; lower - priority process is
swapped out so higher - priority process can be loaded
and executed
Major part of swap time is transfer time ; total transfer
time is directly proportional to the amount of memory
swapped






-Swapping consists of bringing in each process in its entirety , running it for a while , then putting it back on the disk .
-  The main difference between fixed partitions an the variable partitions is that the number , location and size of the partition vary dynamically in the latter as processes come and go .
-  This method gives the flexibility to have partitions that are not to small or to big for a
  process which improves memory utilization .
- But it also complicates allocating and deallocating memory , as well of keeping track of it .
- Loads entire process in memory , runs it , exit
- Is slow ( for big , long - lived processes )
-Wasteful ( might not require everything )

The verb " to swap " is also used to refer to pushing contents of a page out to disk in order to bring other content from disk ; this is distinct from the noun " swapping "

What is Swap out and swap in?

Swap out means to take the program from RAM and to bring them in Hard disk. Swap in means to take the program from Hard disk and again bring them to the RAM.



Advantages of Swapping
  • It helps the CPU to manage multiple processes within a single main memory.
  • It helps to create and use virtual memory.
  • Swapping allows the CPU to perform multiple tasks simultaneously.
  • It improves the main memory utilization.
  •  No external Fragmentation
  •  Simple memory
  •  management algorithm
  •  Swapping is easy ( Equal sized Pages and Page Frames )
                                                           
Disadvantages of Swapping
-If the computer system loses power, the user may lose all information related to the program in case of substantial swapping activity. If the swapping algorithm is not good, the composite method can increase the number of Page Fault and decrease the overall processing performance.
-Internal fragmentation
-Page tables may consume more memory .
-Multi level paging leads to memory reference overhead .

swap time

The total time taken by swapping process includes the time it takes to move the entire process to a secondary disk and then to copy the process back to memory, as well as the time the process takes to regain main memory.



How to calculate swap time 

Let us assume that the user process is of size 2048KB and on a standard hard disk where swapping will take place has a data transfer rate around 1 MB per second. The actual transfer of the 1000K process to or from memory will take



Suppose the user process's size is 2048KB and is a standard hard disk where swapping has a data transfer rate of 1Mbps. Now we will calculate how long it will take to transfer from main memory to secondary memory. Now taking swap-in and swap-out time, the process will take 4000 milliseconds.

           
swap size

Swap space is the portion of virtual memory that is on the hard disk, used when RAM is full. Swap space can be useful to computers in various ways: It can be used as a single contiguous memory which reduces I/O operations to read or write a file.







Comments