mmap()
is a system call, which helps in memory-mapped I/O operations. It allocates a memory region and maps that into the calling process virtual address space so as to enable the application to access the memory.
mmap()
returns a pointer to the mapped area which can be used to access the memory.
Similarly, munmap()
removes the mapping so no further access to the allocated memory remains legal.
These are lower level calls, behaviourally similar to what is offered by memory allocator functions like malloc()
/ free()
on a higher level. However, this system call allow one to have fine grained control over the allocated region behaviour, like,
- memory protection of the mapping (read, write, execute permission)
- (approximate) location of the mapping (see
MAP_FIXED
flag)
- the initial content of the mapped area (see
MAP_UNINITIALIZED
flag)
etc.
You can also refer to the wikipedia article if you think alternate wordings can help you.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…