1ddi_enter_critical(9F)   Kernel Functions for Drivers   ddi_enter_critical(9F)
2
3
4

NAME

6       ddi_enter_critical,  ddi_exit_critical  -  enter  and  exit  a critical
7       region of control
8

SYNOPSIS

10       #include <sys/conf.h>
11       #include <sys/ddi.h>
12       #include <sys/sunddi.h>
13
14
15
16       unsigned int ddi_enter_critical(void);
17
18
19       void ddi_exit_critical(unsignedint ddic);
20
21

INTERFACE LEVEL

23       Solaris DDI specific (Solaris DDI).
24

PARAMETERS

26       ddic    The returned value from the call to  ddi_enter_critical()  must
27               be passed to ddi_exit_critical().
28
29

DESCRIPTION

31       Nearly  all  driver operations can be done without any special synchro‐
32       nization and protection mechanisms beyond those provided by, for  exam‐
33       ple,  mutexes  (see  mutex(9F)). However, for certain devices there can
34       exist a very short critical region of code which must be allowed to run
35       uninterrupted.  The  function ddi_enter_critical() provides a mechanism
36       by which a driver can ask the system to guarantee to the  best  of  its
37       ability  that the current thread of execution will neither be preempted
38       nor interrupted. This stays  in  effect  until  a  bracketing  call  to
39       ddi_exit_critical()  is  made  (with an argument which was the returned
40       value from ddi_enter_critical()).
41
42
43       The driver may not call any functions external to itself in between the
44       time it calls ddi_enter_critical() and the time it calls ddi_exit_crit‐
45       ical().
46

RETURN VALUES

48       The ddi_enter_critical() function returns an  opaque  unsigned  integer
49       which must be used in the subsequent call to ddi_exit_critical().
50

CONTEXT

52       This function can be called from user, interrupt, or kernel context.
53

WARNINGS

55       Driver  writers  should  note that in a multiple processor system  this
56       function does not temporarily suspend other processors from  executing.
57       This function also cannot guarantee to actually block the hardware from
58       doing such things as interrupt acknowledge cycles. What it  can  do  is
59       guarantee that the currently executing thread will not be preempted.
60
61
62       Do not write code  bracketed by ddi_enter_critical() and ddi_exit_crit‐
63       ical() that can get caught in an infinite  loop,  as  the  machine  may
64       crash if you do.
65

SEE ALSO

67       mutex(9F)
68
69
70       Writing Device Drivers
71
72
73
74SunOS 5.11                        16 Jan 2006           ddi_enter_critical(9F)
Impressum