1ddi_periodic_delete(9F) Kernel Functions for Drivers ddi_periodic_delete(9F)
2
3
4
6 ddi_periodic_delete - cancel nanosecond periodic timeout requests
7
9 #include <sys/dditypes.h>
10 #include <sys/sunddi.h>
11
12 void ddi_periodic_delete(ddi_periodic_t req);
13
14
16 Solaris DDI specific (Solaris DDI)
17
19 req ddi_periodic_t opaque value returned by ddi_periodic_add(9F)
20
21
23 The ddi_periodic_delete() function cancels the ddi_periodic_add(9F)
24 request that was previously issued.
25
26
27 As with untimeout(9F), calling ddi_periodic_delete() against a periodic
28 timeout request which is either running on another CPU, or has already
29 been canceled causes no problems. Unlike untimeout(9F), there are no
30 restrictions on the lock which might be held across the call to
31 ddi_periodic_delete().
32
34 The ddi_periodic_delete() function may be called from user or kernel
35 context.
36
38 Example 1 Cancelling a timeout request
39
40
41 In the following example, the device driver cancels the timeout request
42 by calling ddi_periodic_delete() against the request that was previ‐
43 ously issued.
44
45
46 /*
47 * Stop the periodic timer
48 */
49 static void
50 stop_periodic_timer(struct my_state *statep)
51 {
52 ddi_periodic_delete(statep->periodic_id);
53 delay(1); /* wait for one tick */
54 mutex_destory(&statep->lock);
55 }
56
57 static void
58 start_periodic_timer(struct my_state *statep)
59 {
60 hrtime_t interval = CHECK_INTERVAL;
61
62 mutex_init(&statep->lock, NULL, MUTEX_DRIVER,
63 (void *)DDI_IPL_0);
64
65 /*
66 * Register my_callback which is invoked periodically
67 * in CHECK_INTERVAL in kernel context.
68 */
69 statep->periodic_id = ddi_periodic_add(my_periodic_func,
70 statep, interval, DDI_IPL_0);
71 }
72
73 static void
74 my_periodic_func(void *arg)
75 {
76 /*
77 * This handler is invoked periodically.
78 */
79 struct my_state *statep = (struct my_state *)arg;
80
81 mutex_enter(&statep->lock);
82 if (load_unbalanced(statep)) {
83 balance_tasks(statep);
84 }
85 mutex_exit(&statep->lock);
86 }
87
88
90 cv_timedwait(9F), ddi_intr_get_pri(9F), ddi_periodic_add(9F),
91 delay(9F), drv_usectohz(9F), qtimeout(9F), quntimeout(9F), timeout(9F),
92 untimeout(9F)
93
95 There might be a race between a callback invocation and ddi_peri‐
96 odic_delete(). A device driver should take a responsibility for this
97 avoidance if needed by using the kernel synchronization such as a mutex
98 lock or calling delay(9F) as in the example above.
99
100
101
102SunOS 5.11 6 May 2009 ddi_periodic_delete(9F)