Overview

In this reading we’ll look at how an area of memory can be associated with a file on disk using a process called memory mapping. Memory mapping is an integral part of effective sharing of libraries as well as the fork and execve functions.

Required Reading

Section 9.8 (pp. 833-839) from the course textbook.

Learning Objectives

BASIC Learning Objectives

Each student will be responsible for learning and demonstrating proficiency in the following objectives PRIOR to the class meeting. The reading quiz will test these objectives.

  1. Explain how demand paging improves efficiency.
  2. Compare and contrast memory mapping an area to a regular file with mapping to an anonymous file.
  3. Compare and contrast a shared object with a private object that uses copy-on-write.
  4. Describe why fork uses copy-on-write.
  5. Summarize the four steps taken to load a program using execve.
  6. Describe the functionality of the mmap and munmap system calls.

ADVANCED Learning Objectives

The following objectives should be mastered by each student DURING and FOLLOWING the class session through active work and practice.

  1. Given a scenario that describes the file to use, allowed permissions, and a list of processes with which we want to share data, use mmap to create a new memory mapped region.
  2. Trace and write C programs that create memory mapped areas using mmap.

Pre-class Exercises

These exercises are geared towards mastering the BASIC learning objectives listed above. You are expected to submit them before class and it is highly recommended that you complete them before attempting the reading quiz.

  1. Briefly explain what, if any, effect demand paging has on the following components of system performance:

  2. What are the initial contents of a page that is memory mapped to an anonymous file?

  3. For each of the following virtual memory areas, indicate whether it is memory mapped to a regular file, anonymous file, both, or neither.