'\" te .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH MCTL 3UCB "Oct 30, 2007" .SH NAME mctl \- memory management control .SH SYNOPSIS .LP .nf \fB/usr/ucb/cc\fR [ \fIflag\fR ... ] \fIfile\fR ... #include #include \fBint\fR \fBmctl\fR(\fIaddr\fR, \fIlen\fR, \fIfunction\fR, \fIarg\fR) \fBcaddr_t\fR \fIaddr\fR; \fBsize_t\fR \fIlen\fR; \fBint\fR \fIfunction\fR; \fBint\fR \fIarg\fR; .fi .SH DESCRIPTION .sp .LP \fBmctl()\fR applies a variety of control functions over pages identified by the mappings established for the address range [\fIaddr, addr + len\fR). The function to be performed is identified by the argument \fIfunction\fR. Valid functions are defined in \fB\fR as follows: .sp .ne 2 .na \fB\fBMC_LOCK\fR\fR .ad .RS 15n Lock the pages in the range in memory. This function is used to support \fBmlock()\fR. See \fBmlock\fR(3C) for semantics and usage. \fIarg\fR is ignored. .RE .sp .ne 2 .na \fB\fBMC_LOCKAS\fR\fR .ad .RS 15n Lock the pages in the address space in memory. This function is used to support \fBmlockall()\fR. See \fBmlockall\fR(3C) for semantics and usage. \fIaddr\fR and \fIlen\fR are ignored. \fIarg\fR is an integer built from the flags: .sp .ne 2 .na \fB\fBMCL_CURRENT\fR\fR .ad .RS 15n Lock current mappings .RE .sp .ne 2 .na \fB\fBMCL_FUTURE\fR\fR .ad .RS 15n Lock future mappings .RE .RE .sp .ne 2 .na \fB\fBMC_SYNC\fR\fR .ad .RS 15n Synchronize the pages in the range with their backing storage. Optionally invalidate cache copies. This function is used to support \fBmsync()\fR. See \fBmsync\fR(3C) for semantics and usage. \fIarg\fR is used to represent the \fIflags\fR argument to \fBmsync()\fR. It is constructed from an OR of the following values: .sp .ne 2 .na \fB\fBMS_SYNC\fR\fR .ad .RS 17n Synchronized write .RE .sp .ne 2 .na \fB\fBMS_ASYNC\fR\fR .ad .RS 17n Return immediately .RE .sp .ne 2 .na \fB\fBMS_INVALIDATE\fR\fR .ad .RS 17n Invalidate mappings .RE \fBMS_ASYNC\fR returns after all \fBI/O\fR operations are scheduled. \fBMS_SYNC\fR does not return until all \fBI/O\fR operations are complete. Specify exactly one of \fBMS_ASYNC\fR or \fBMS_SYNC\fR. \fBMS_INVALIDATE\fR invalidates all cached copies of data from memory, requiring them to be re-obtained from the object's permanent storage location upon the next reference. .RE .sp .ne 2 .na \fB\fBMC_UNLOCK\fR\fR .ad .RS 15n Unlock the pages in the range. This function is used to support \fBmunlock()\fR. \fIarg\fR is ignored. .RE .sp .ne 2 .na \fB\fBMC_UNLOCKAS\fR\fR .ad .RS 15n Remove address space memory lock, and locks on all current mappings. This function is used to support \fBmunlockall()\fR. \fIaddr\fR and \fIlen\fR must have the value 0. \fIarg\fR is ignored. .RE .SH RETURN VALUES .sp .LP \fBmctl()\fR returns \fB0\fR on success, \fB\(mi1\fR on failure. .SH ERRORS .sp .LP \fBmctl()\fR fails if: .sp .ne 2 .na \fB\fBEAGAIN\fR\fR .ad .RS 10n Some or all of the memory identified by the operation could not be locked due to insufficient system resources. .RE .sp .ne 2 .na \fB\fBEBUSY\fR\fR .ad .RS 10n \fBMS_INVALIDATE\fR was specified and one or more of the pages is locked in memory. .RE .sp .ne 2 .na \fB\fBEINVAL\fR\fR .ad .RS 10n \fIaddr\fR is not a multiple of the page size as returned by \fBgetpagesize()\fR. .RE .sp .ne 2 .na \fB\fBEINVAL\fR\fR .ad .RS 10n \fIaddr\fR and/or \fIlen\fR do not have the value 0 when \fBMC_LOCKAS\fR or \fBMC_UNLOCKAS\fR are specified. .RE .sp .ne 2 .na \fB\fBEINVAL\fR\fR .ad .RS 10n \fIarg\fR is not valid for the function specified. .RE .sp .ne 2 .na \fB\fBEIO\fR\fR .ad .RS 10n An I/O error occurred while reading from or writing to the file system. .RE .sp .ne 2 .na \fB\fBENOMEM\fR\fR .ad .RS 10n Addresses in the range [\fIaddr, addr + len\fR) are invalid for the address space of a process, or specify one or more pages which are not mapped. .RE .sp .ne 2 .na \fB\fBEPERM\fR\fR .ad .RS 10n The process's effective user \fBID\fR is not superuser and one of \fBMC_LOCK MC_LOCKAS\fR, \fBMC_UNLOCK\fR, or \fBMC_UNLOCKAS\fR was specified. .RE .SH SEE ALSO .sp .LP \fBmmap\fR(2), \fBmemcntl\fR(2), \fBgetpagesize\fR(3C), \fBmlock\fR(3C), \fBmlockall\fR(3C), \fBmsync\fR(3C) .SH NOTES .sp .LP Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported.