Merge commit 'b31320a79e2054c6739b5229259dbf98f3afc547' into merges
[unleashed.git] / share / man / man3c / plock.3c
blob4051b6a19f8efa3850bddf3fa849f97d7cf5f491
1 '\" te
2 .\" Copyright 1989 AT&T.  Copyright (c) 2004, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH PLOCK 3C "Mar 22, 2004"
7 .SH NAME
8 plock \- lock or unlock into memory process, text, or data
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/lock.h>
14 \fBint\fR \fBplock\fR(\fBint\fR \fIop\fR);
15 .fi
17 .SH DESCRIPTION
18 .sp
19 .LP
20 The \fBplock()\fR function allows the calling process to lock or unlock into
21 memory its text segment (text lock), its data segment (data lock), or both its
22 text and data segments (process lock). Locked segments are immune to all
23 routine swapping. The effective user ID of the calling process must be
24 super-user to use this call.
25 .sp
26 .LP
27 The \fBplock()\fR function performs the function specified by \fIop\fR:
28 .sp
29 .ne 2
30 .na
31 \fB\fBPROCLOCK\fR\fR
32 .ad
33 .RS 12n
34 Lock text and data segments into memory (process lock).
35 .RE
37 .sp
38 .ne 2
39 .na
40 \fB\fBTXTLOCK\fR\fR
41 .ad
42 .RS 12n
43 Lock text segment into memory (text lock).
44 .RE
46 .sp
47 .ne 2
48 .na
49 \fB\fBDATLOCK\fR\fR
50 .ad
51 .RS 12n
52 Lock data segment into memory (data lock).
53 .RE
55 .sp
56 .ne 2
57 .na
58 \fB\fBUNLOCK\fR\fR
59 .ad
60 .RS 12n
61 Remove locks.
62 .RE
64 .SH RETURN VALUES
65 .sp
66 .LP
67 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
68 returned and \fBerrno\fR is set to indicate the error.
69 .SH ERRORS
70 .sp
71 .LP
72 The \fBplock()\fR function fails and does not perform the requested operation
73 if:
74 .sp
75 .ne 2
76 .na
77 \fB\fBEAGAIN\fR\fR
78 .ad
79 .RS 10n
80 Not enough memory.
81 .RE
83 .sp
84 .ne 2
85 .na
86 \fB\fBEINVAL\fR\fR
87 .ad
88 .RS 10n
89 The \fIop\fR argument is equal to \fBPROCLOCK\fR and a process lock, a text
90 lock, or a data lock already exists on the calling process; the \fIop\fR
91 argument is equal to \fBTXTLOCK\fR and a text lock or a process lock already
92 exists on the calling process; the \fIop\fR argument is equal to \fBDATLOCK\fR
93 and a data lock or a process lock already exists on the calling process; or the
94 \fIop\fR argument is equal to \fBUNLOCK\fR and no lock exists on the calling
95 process.
96 .RE
98 .sp
99 .ne 2
101 \fB\fBEPERM\fR\fR
103 .RS 10n
104 The {\fBPRIV_PROC_LOCK_MEMORY\fR} privilege is not asserted in the effective
105 set of the calling process.
108 .SH USAGE
111 The \fBmlock\fR(3C) and \fBmlockall\fR(3C) functions are the preferred
112 interfaces for process locking.
113 .SH ATTRIBUTES
116 See \fBattributes\fR(5) for descriptions of the following attributes:
121 box;
122 c | c
123 l | l .
124 ATTRIBUTE TYPE  ATTRIBUTE VALUE
126 MT-Level        MT-Safe
129 .SH SEE ALSO
132 \fBexec\fR(2), \fBexit\fR(2), \fBfork\fR(2), \fBmemcntl\fR(2), \fBmlock\fR(3C),
133 \fBmlockall\fR(3C), \fBattributes\fR(5)