Chapter 5 Memory Management
Objectives
To introduce the concept of the address space of a process. To show how processes can share memory, in particular, writeable data. To study the memory management function of OSs. To show how virtual to physical address translation and memory protection are supported by hardware.
Points to emphasise
- The concept of the virtual address space of a process is fundamental.
- Segmentation is concerned with a logical division of the virtual address space. Paging is concerned with physical memory management and is transparent to the OSs client software.
- Segmentation supports relatively fine-grain sharing and protection.
- The hardware knows about pages (fixed size blocks). Segments may be known to the hardware or be managed only by the OS.
- The memory management function has to respond to both hardware events and requests from clients for memory management services.
- There may be multiple copies of shared, writeable data in the caches of a multiprocessor.
Possible difficulties
If this topic is treated in depth here it can hold up the development of the main theme. My students have had an outline of basic OS functions before coming to concurrent systems (CS). I cover memory management in detail in a course which follows CS. At that stage the students are more able to understand issues, trade-offs and potential directions of development.
Teaching hints
- An example of an MMU in a machine used by the students, can be used in place of the R2000/3000 example in the book.
- Explore the implications of having a large virtual address space (say 32 bits, 4Gbytes). Get the students to work out how large a process page table could be for some specific page size, say 1Kbytes. Ask for suggestions on how to rationalise this space requirement. Lead up to the idea of a page table for main memory and process page tables for backing store, held on backing store.
- Explore the implications of having a large amount of physical memory.
How much longer will paging out be needed? What are the implications of a crash in which main memory is lost?
- Work out how long memory to memory copying takes of data blocks of, say, 4K, 8K, 16K, 32K bytes in size (use the instructions and timings of a machine well-known to the students). Get the students to think about using memory management for moving data buffers (I/O and comms.) between the system and processes and between processes.