Memory management in operating systems is often a very interesting
and complex task. It consists of some or all of the following:
separating processes into their own address spaces so that one misbehaving
process cannot interfere with another, nor can it interfere with the operating
system
implementing virtual memory so that
a process' image can be physically scattered throughout memory while
appearing to remain contiguous.
a process' image can actually be larger than physical memory
better use can be made or real memory by keeping only those parts of
a process image in memory that have a current need to be in memory.
allocating storage for a process' code and data
allocating storage for a process' stack
allocating storage for a process' heap (dynamically allocated storage
- not necessarily organizes as a heap data structure).
The top two features of memory management require hardware support that
the PDP-11 never had. Thus XINU does not separate processes into their
own address spaces, nor does it implement virtual memory. There is a recent version of XINU which has virtual memory support for the PC, but it is not described in the textbook. Thus, we will discuss the non-virtual memory case in more detail. XINU does, however,
allocate memory for the various parts of a process image. Allocating memory
for the code and data are trivial in XINU because they are done by the
linker before runtime (remember that in XINU process code (text) and data
are linked contiguously at the bottom of memory). Allocating storage for
the heap and stack are runtime operations and are therefore discussed here.