The mmap and munmap system calls allow UNIX programs to exert detailed control over their address spaces.

computer science

Description

mmap 

The mmap and munmap system calls allow UNIX programs to exert detailed control over their address spaces. They can be used to share memory among processes, to map files into process address spaces, and as part of user-level page fault schemes such as the garbage-collection algorithms. In this lab you'll add mmap and munmap to xv6, focusing on memory-mapped files. Fetch the xv6 source for the lab and check out the mmap branch:


To use this version of xv6, you will need to install the toolchain for your ubuntu image: follow the instructions at this page under “other linux distributions


The toolchain is large and takes a while to install. You may need to expand your ubuntu image hard disk: 


mmap can be called in many ways, but this assignment requires only a subset of its features relevant to memory-mapping a file. You can assume that addr will always be zero, meaning that the kernel should decide the virtual address at which to map the file. mmap returns that address, or 0xffffffffffffffff if it fails. length is the number of bytes to map; it might not be the same as the file's length. prot indicates whether the memory should be mapped readable, writeable, and/or executable; you can assume that prot is PROT_READ or PROT_WRITE or both. flags will be either MAP_SHARED, meaning that modifications to the mapped memory should be written back to the file, or MAP_PRIVATE, meaning that they should not. You don't have to implement any other bits in flags. fd is the open file descriptor of the file to map. You can assume offset is zero (it's the starting point in the file at which to map)


Related Questions in computer science category