Make your own free website on Tripod.com

COMPARISON OF PAGING AND SEGMENTATION

In order to compare these two virtual addresing schemes and to discover situations where each is appropriate, let us evaluate each scheme using the folowing criteria:

  1. Memory Utilization
  2. Memory Allocation
  3. Sharing of Code

Memory Utilization Paging achieves very good utilization of memory. One can arrange concurrent user programs in memory, each being represented by only those pages that it is currently using. the main memory available to user programs will normally be allocated and in active use.

Of course , paging entails the allocation of some integral number of page frames to a process; it is unlikely that a process will actually fit exactly in an integral number of page frames and consequently one has internal fragmentation.Though internal fragmentation is present in paged systems, the wastage is not much.It will only be on the last pages of programs currently being multiprogrammed.

As a system runs, segments are loaded, used and then freed. Once freed, the spaces in memory that they occupied are reallocated.It would be typical for an incoming segment to exactly fit in the space released by a departing segment; consequently, one has extrnal fragmentation.

Memory Allocation Paging simplifies the task of memory allocation. With paging, the system has a pool of identical resource units - the page frames.Requests by processes for additional resources (page frames) can be satisfied by the allocation of any of the free page frame.

The only problem that may arise are due to the requests for new page frames coming much faster than the voluntary release of page frames (this situation is normal during job termination). Usually there will be no page frame free; so the system has to preempt a page frame, i.e., swap out a page occupaying a frame. This preempted page frame may be a frame allocated to the same process.

Allocation of spaces for segment is more difficult. Memory allocation schemes that attempt to find the best-fit/ first-fit/ worst fit are all very well so long as there are "holes" suffecient in size to take a new segment. but if external fragmentation has got too rampant, then though there may be lots of unused memory there might be no areas of suffecient size to allocate to a new segment.

Then the system could "compact" memory - but it is firesome, lots of copying, lots of updating of segment maps, and nesty restrictions of I/O is in progress for any of the segments that must be moved. Alternatively, the system can try swapping segments out. This is even more difficult. The system could try to swap out several neighboring segments, or maybe one segments adjacent to a couple of small "holes" so as to get a "hole" suffecient for the new segment.This however, involves lots of messy adress translations and calculations - and these will have to be repeated when a swapped out segment is swapped back in.

Sharing of CodeSegmentation was designed in part to allow for sharing of code and / or read- only data among processes.

Segments can be made to specify allowed usage on it - any execute - only/ read-only segment is intrinsically sharable. The system can keep track of segments loaded (particularly easy if a segment identifier can be related to a file identifier as a possible in many segmented system) and can determine when one process is requesting a segment already loaded by some other process. Arrangements for sharing simply require that the segment maps of various processes are kept consistent.

Sharing is difficult in paged systems. Pages do not correspond to logical divisions of a program. One FORTRAN program on a paged system might on any page contain some marvelous mixture of code and data. Each process must keep its private data separate.

CLICK