Index of Section 2 Manual Pages
| Interix / SUA | memcntl.2 | Interix / SUA |
memcntl(2) memcntl(2)
memcntl()
memcntl - manage memory in mappings
SYNOPSIS
#include
int memcntl(void *addr, size_t len, int cmd,
void *arg, int attr, int mask)
DESCRIPTION
The memcntl(2) call controls and manages a mapped address space in the
range [addr addr + len]. The attr argument selects the pages to be
affected; it contains a bit pattern of page attributes which are ORed
together.
Page mapping
SHARED Page is mapped shared
PRIVATE Page is mapped private
Page protection
PROT_READ Page is readable
PROT_WRITE Page is writeable
PROT_EXEC Page is executable
Process criteria
PROC_DATA Process data: write permission for privately-mapped
segments
PROC_TEXT Process text: read and execute permission for
privately-mapped segments
The cmd argument specifies the actual operation. The arg argument may
modify the actual command, and is usually a bit pattern ORed together. The
file defines these operations:
MC_LOCK
Lock the pages in the range that have the specified attributes.
Although different mappings may cause the same page to be locked more
than once, the locks do not nest within a particular mapping. One
unlock operation undoes all the locks held on a page by a process, but
locks held by aanother process are held in memory until the locking
process has released the lock. (If a locked page is removed or
deleted, that implicitly unlocks it.)
The value of arg must be 0.
MC_LOCKAS
Lock the pages in the address space that have the specified
attributes. In this case, the arg value controls whether the locked
pages are mapped in the current address space or ones that will be
mapped later, or both.
The addr value must be NULL and the len value must be 0.
Values that can be ORed into arg are:
MCL_CURRENT
Lock the current mappings
MCL_FUTURE
Lock all mappings added to the address space, so long as there is
sufficient memory
MC_UNLOCK
Unlock all of the pages in the range that have the specified
attributes. The value of arg must be 0.
MC_UNLOCKAS
Unlock any locks on the address space (MC_LOCKAS) and remove locks on
all pages in the address space that have the specified attributes.
The mask argument is reserved for future use and must be set to 0.
RETURN VALUES
The memcntl(2) utility exits with status 0 for success, and -1 if an error
occurred.
ERRORS
The memcntl(2) function can fail for the following reasons:
[EAGAIN]
Insufficient resources to lock some or all of the memory.
[EBUSY]
One of the pages is locked in memory and MS_INVALIDATE was the
command.
[EINVAL]
The addr is invalid. It must be a multiple of the page size. If the
command is MC_LOCKAS or MC_UNLOCKAS, the value of addr is not NULL, or
the value of len is not zero. It may also mean the value of arg was
not correct for the command given.
[EIO]
An I/O error occurred.
[ENOMEM]
The addresses in the range are not valid for the address space of the
process, or are for pages that aren't mapped.
[EPERM]
A locking command was specified and the effective user ID does not
have appropriate privileges.
SEE ALSO
fork(2)
mmap(2)
mctl(3)
msync(3)
sysconf(2)
USAGE NOTES
The memcntl function is thread safe.
The memcntl function is not async-signal safe.