Mmap maps a file or other object into memory. Mmap can also implement shared memory. mmap function calls enable shared memory between processes by mapping the same file. After the file is mapped to the process address space, the process can manipulate the file like read-write memory.
Function prototype: void* mmap(void* addr,size_t length,int prot,int flags,int fd,off_t offset);
Addr: The start address of the map area, set to 0, indicates the system determines the starting address of the map area
Length: The size of the map area. length units are bytes
Prot: The desired memory protection flag. Take the following values:
Port_exec: page content can be executed Port_read: page content can be read
Port_write: page content can be written to Prot_none: page content is inaccessible
Flag: Specifies the type of the mapped object, and whether the mapping options are shared with the mapped page.
map_shared: shares the mapping space with all other processes that map this object.
map_fixed:
FD: Valid file descriptor. Returns, by the general open () function, whose value can be set to-1. You need to specify the flags parameter to &NBSP ; Map_anon, indicating that the anonymous mapping is in progress.
Offset: The starting point for the content of the mapped object.
Return value: Succeeded, returns a pointer to the mapped area; failed, returns-1.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/85/80/wKiom1el5IORFskaAAB9GIoxJaM705.png "style=" float: none; "title=" 1.PNG "alt=" Wkiom1el5iorfskaaab9gioxjam705.png "/>
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/85/80/wKioL1el5ITRtUhdAAAUW3Pui8w870.png "style=" float: none; "title=" 3.PNG "alt=" Wkiol1el5itrtuhdaaauw3pui8w870.png "/>
This article from "Together to see the Stars" blog, reproduced please contact the author!
mmap function for Shared memory