This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ent process’s context to point to the entry point in the text area. The next time this process is scheduled, it will begin execution from the entry point. Linux will swap in code and data pages as needed. 10.8.4 User-level Memory Mapping with the mmap Function
Unix processes can use the mmap function to create new areas of virtual memory and to map objects into these areas.
#include <unistd.h> #include <sys/mman.h> void *mmap(void *start, size t length, int prot, int flags, int fd, off t offset);
returns: pointer to mapped area if OK, -1 on error The mmap function asks the kernel to create a new virtual memory area, preferably one that starts at address start, and to map a contiguous chunk of the object speciﬁed by ﬁle descriptor fd to the new area. The contiguous object chunk has a size of length bytes and starts at an offset of offset bytes from the beginning of the ﬁle. The start address is merely a hint, and is usually speciﬁed as NULL. For our purposes, we will always ass...
View Full Document
This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.
- Spring '10
- The American