Compare the main memory organization schemes of contiguousme
Compare the main memory organization schemes of contiguous-memory allocation, pure
segmentation, and pure paging with respect to the following issues:
a. External fragmentation
b. Internal fragmentation
c. Ability to share code across processes
Solution
a). External fragmentation is
 Contiguous allocation with the fixed size
 partions are not suffer from the external fragmentation, but
 contiguous allocation with variable sized partitions. Pure
 paging does not suffer from external fragmentation, since
 partitions and pages are fixed in size. Segmentation does suffer
 from external fragmentation.
 b. )Internal fragmentation
 Segmentation and variable-sized
 partitions do not suffer from internal fragmentation, since by
 definition, a segment/partition is exactly as large as it needs to
 be. However, the contiguous allocation with fixed size partitions and
 paging both may suffering from internal fragmentation when
 partitions and pages are not completely filled.
 c.) Ability to share code across processes
 Contiguous allocation
 provides no support for the code sharing.
 In segmentation, as long as the segments of a process do not mix
 text and data, we can easily share code between processes.
We adjust the segment tables of the each process point to the
 same segment of code in memory. For security reasons, however,
 it would probably be desirable to have some method of
 preventing processes from modifying the code, since doing so would
 allow one process to change the code executed by another.
 In pure paging, code can be shared across processes simply by
 sharing page frames. To do this, adjust the page tables of the
 two processes so that their different logical pages map to the
 same physical page frame. However, we do need to make certain
 that no page frame contains the data, which should not be
 shared. We could accomplish this by, for example, padding the
 last page of the text segment of the process with
 no-op
 machine
 language instructions
contiguous memory allocation:
the size of the partition
in which a process resides was fixed, the compiler (or loader, if
sophisticated enough must determine at compile time/load time the
maximum distance between the both of stack and the heap in order to
calculate the size of the process address space. If this space is
made too large, memory will be wasted. If the space is too small,
the stack and the heap will collide and corrupt the data or crash the
program.
In addition, the space between the top of the (downward
growing) stack and the (upward growing) heap was unused, leading
to wasted memory or dumped memory.
pure segmentation:
If the stack and heap are the placed in the same
segment the memory will either be wasted, or we risk the possibility
of a stack/heap collision. If the stack and heap are placed in
different segments, we may be able to expand the heap, but the
maximum stack size is fixed at load time, since the stack grows
downward. One solution on a system that uses pure
segmentation is to redefine the stack to grow upwards from the
bottom of its segment.
pure paging:
Pure paging suffers from the same problem as
contiguous memory allocation. since we need to allocate the frame
for each page of the process, even if the page is unused. We can
solve this problem by combining pure paging with a scheme
called “virtual memory”.


