Index of Section 3 Manual Pages
| Interix / SUA | mctl.3 | Interix / SUA |
mctl(3) mctl(3)
mctl()
NAME
mctl() - control memory management
SYNOPSIS
#include
int mctl(void *addr, size_t len, int cmd, int arg)
DESCRIPTION
The mctl(3) call controls the management of memory for the pages mapped in
the range [addr, addr + len]. The actual management command is specified
by cmd, which can be one of:
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.
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 mctl(3) call is actually an historical version of memcntl(2); it is
equivalent to:
memcntl(addr, len, cmd, (void *)arg,
PROT_READ|PROT_WRITE|PROT_EXEC|SHARED|PRIVATE , 0)
See the memcntl(2) man page for more information.
RETURN VALUES
The mctl(3) call returns 0 on success and -1 on failure. On failure, it
sets the value of errno to indicate the error.
ERRORS
The mctl(3) call 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.
[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
memcntl(2)
USAGE NOTES
The mctl function is thread safe.
The mctl function is not async-signal safe.