Skip to content

Memory operation

Memory Operation

Memory allocation

Memory copy

map or unmap file or device into memory

void *mmap(void addr[.length], size_t length, int prot, int flags, int fd, off_t offset)
* addr : specify the starting address * addr == NULL : the kernel choose to create the mapping * addr != NULL : the kernel take it as a hint to place

* `length` : the length of the mapping
  • proc : desire memory protection of the mapping

  • fdoffsetlength:The content of file mapping are initialize using length byte starting at offset in the file fd

Retuen value * Success : Return a pointer to the mapped area * On error : Return MAP_FAILED ((void*) -1)


int mumap(void addr[.length], size_t length)
Delete the mapping for the specified address range

Return values * Success : Return 0 * Failure : Return -1