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"
8 ddi_enter_critical, ddi_exit_critical \- enter and exit a critical region of
15 #include <sys/sunddi.h>
19 \fBunsigned int\fR \fBddi_enter_critical\fR(\fBvoid\fR);
24 \fBvoid\fR \fBddi_exit_critical\fR(\fBunsignedint\fR \fIddic\fR);
30 Solaris DDI specific (Solaris DDI).
38 The returned value from the call to \fBddi_enter_critical()\fR must be passed
39 to \fBddi_exit_critical()\fR.
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).
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.
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.
67 This function can be called from user, interrupt, or kernel context.
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.
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.
87 \fIWriting Device Drivers\fR