ksh: build with __EXTENSIONS__ to expose confstr
[unleashed.git] / share / man / man9f / ddi_enter_critical.9f
blob3516ab7a15c987ec5da639eadbbc706a8a1e6cdb
1 '\" te
2 .\"  Copyright (c) 2006, 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 DDI_ENTER_CRITICAL 9F "Jan 16, 2006"
7 .SH NAME
8 ddi_enter_critical, ddi_exit_critical \- enter and exit a critical region of
9 control
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <sys/conf.h>
14 #include <sys/ddi.h>
15 #include <sys/sunddi.h>
19 \fBunsigned int\fR \fBddi_enter_critical\fR(\fBvoid\fR);
20 .fi
22 .LP
23 .nf
24 \fBvoid\fR \fBddi_exit_critical\fR(\fBunsignedint\fR \fIddic\fR);
25 .fi
27 .SH INTERFACE LEVEL
28 .sp
29 .LP
30 Solaris DDI specific (Solaris DDI).
31 .SH PARAMETERS
32 .sp
33 .ne 2
34 .na
35 \fB\fIddic\fR\fR
36 .ad
37 .RS 8n
38 The returned value from the call to \fBddi_enter_critical()\fR must be passed
39 to \fBddi_exit_critical()\fR.
40 .RE
42 .SH DESCRIPTION
43 .sp
44 .LP
45 Nearly all driver operations can be done without any special synchronization
46 and protection mechanisms beyond those provided by, for example, mutexes (see
47 \fBmutex\fR(9F)). However, for certain devices there can exist a very short
48 critical region of code which \fBmust\fR be allowed to run uninterrupted. The
49 function \fBddi_enter_critical()\fR provides a mechanism by which a driver can
50 ask the system to guarantee to the best of its ability that the current thread
51 of execution will neither be preempted nor interrupted. This stays in effect
52 until a bracketing call to \fBddi_exit_critical()\fR is made (with an argument
53 which was the returned value from \fBddi_enter_critical()\fR).
54 .sp
55 .LP
56 The driver may not call any functions external to itself in between the time it
57 calls \fBddi_enter_critical()\fR and the time it calls
58 \fBddi_exit_critical()\fR.
59 .SH RETURN VALUES
60 .sp
61 .LP
62 The \fBddi_enter_critical()\fR function returns an opaque unsigned integer
63 which must be used in the subsequent call to \fBddi_exit_critical()\fR.
64 .SH CONTEXT
65 .sp
66 .LP
67 This function can be called from user, interrupt, or kernel context.
68 .SH WARNINGS
69 .sp
70 .LP
71 Driver writers should note that in a multiple processor system  this function
72 does not temporarily suspend other processors from executing. This function
73 also cannot guarantee to actually block the hardware from doing such things as
74 interrupt acknowledge cycles. What it \fBcan\fR do is guarantee that the
75 currently executing thread will not be preempted.
76 .sp
77 .LP
78 Do not write code  bracketed by \fBddi_enter_critical()\fR and
79 \fBddi_exit_critical()\fR that can get caught in an infinite loop, as the
80 machine may crash if you do.
81 .SH SEE ALSO
82 .sp
83 .LP
84 \fBmutex\fR(9F)
85 .sp
86 .LP
87 \fIWriting Device Drivers\fR