Swapping

 

Swapping
A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution
nBacking store – fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images
nRoll 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
nMajor part of swap time is transfer time; total transfer time is directly proportional to the amount of memory swapped
nModified versions of swapping are found on many systems (i.e., UNIX, Linux, and Windows)
System maintains a ready queue of ready-to-run processes which have memory images on disk
Schematic View of Swapping
 
 
Contiguous Allocation
 
·        Main memory usually into two partitions:
·        Resident operating system, usually held in low memory with interrupt vector
User processes then held in high memory
·        nRelocation registers used to protect user processes from each other, and from changing operating-system code and data
·        Base register contains value of smallest physical address
·        Limit register contains range of logical addresses – each logical address must be less than the limit register
·        MMU maps logical address dynamically
Hardware Support for Relocation and Limit Registers
 
 

 
·        Multiple-partition allocation
·        Hole – block of available memory; holes of various size are scattered throughout memory
·        When a process arrives, it is allocated memory from a hole large enough to accommodate it
·        Operating system maintains information about:

 
 
 
 
·        a) allocated partitions    b) free partitions (hole)
 
 
 


Dynamic Storage-Allocation Problem
·        First-fit: Allocate the first hole that is big enough
·        Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size Produces the smallest leftover hole
·        Worst-fit: Allocate the largest hole; must also search entire list 
·        Produces the largest leftover hole
·       First-fit and best-fit better than worst-fit in terms of speed and storage utilization
Fragmentation
·        External Fragmentation – total memory space exists to satisfy a request, but it is not contiguous
·        Internal Fragmentation – allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used
·        Reduce external fragmentation by compaction
·        Shuffle memory contents to place all free memory together in one large block
·        Compaction is possible only if relocation is dynamic, and is done at execution time.
 
 
·        I/O problem
4Latch job in memory while it is involved in I/O
4Do I/O only into OS buffers

Dear Guest,
Spend a minute to Register in a few simple steps, for complete access to the Social Learning Platform with Community Learning Features and Learning Resources.
If you are part of the Learning Community already, Login now!
0
Your rating: None

Posted by



Wed, 05/20/2009 - 11:09

Share

Collaborate