stmf: avoid set but not used errors
[unleashed.git] / share / man / man9f / ddi_periodic_delete.9f
blob84cd2d8990f0c860d17cab06797e6d86c7062ccd
1 '\" te
2 .\" Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
3 .\" Copyright 2013, Joyent, Inc. All Rights Reserved.
4 .\"  Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
5 .\" 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. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.
6 .\"  See the License for the specific language governing permissions and limitations under the License. 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
7 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
8 .TH DDI_PERIODIC_DELETE 9F "Feb 12, 2014"
9 .SH NAME
10 ddi_periodic_delete \- cancel periodic function invocation requests
11 .SH SYNOPSIS
12 .LP
13 .nf
14 #include <sys/dditypes.h>
15 #include <sys/sunddi.h>
17 \fBvoid\fR \fBddi_periodic_delete\fR(\fBddi_periodic_t\fR \fIrequest\fR\fB);\fR
18 .fi
20 .SH INTERFACE LEVEL
21 .sp
22 .LP
23 Solaris DDI specific (Solaris DDI)
24 .SH PARAMETERS
25 .sp
26 .ne 2
27 .na
28 \fB\fIrequest\fR\fR
29 .ad
30 .RS 7n
31 \fBddi_periodic_t\fR opaque value returned by \fBddi_periodic_add\fR(9F)
32 .RE
34 .SH DESCRIPTION
35 .sp
36 .LP
37 The \fBddi_periodic_delete()\fR function cancels a periodic invocation request
38 previously established with \fBddi_periodic_add\fR(9F).
39 .sp
40 .LP
41 It is not possible to cancel a periodic invocation request from within the
42 periodic callback itself; to do so is a programming error that will panic the
43 system.  Instead, requests must be cancelled from some other user or kernel
44 context routine, such as the \fBdetach\fR(9E) entry point of a module.
45 .sp
46 .LP
47 If the callback function is already executing (for instance, on another CPU)
48 when the request is cancelled, \fBddi_periodic_delete()\fR will block until
49 it finishes executing and is completely unregistered.  Because of this, locks
50 acquired by the callback function must not be held across the call to
51 \fBddi_periodic_delete()\fR or a deadlock may result.
52 .sp
53 .LP
54 The callback will not be invoked again after the call to
55 \fBddi_periodic_delete()\fR returns.
56 .SH CONTEXT
57 .sp
58 .LP
59 The \fBddi_periodic_delete()\fR function may be called from user or kernel
60 context.
61 .SH EXAMPLES
62 .LP
63 \fBExample 1 \fRCancelling a periodic invocation request
64 .sp
65 .LP
66 In the following example, the device driver cancels the request
67 by calling \fBddi_periodic_delete()\fR and passing the opaque \fIrequest\fR
68 identifier returned by a previous call to \fBddi_periodic_add\fR(9F).
70 .sp
71 .in +2
72 .nf
74  * Stop the periodic timer.
75  */
76 static void
77 stop_periodic_timer(struct my_state *statep)
79         ddi_periodic_delete(statep->periodic_id);
80         mutex_destroy(&statep->lock);
83 static void
84 start_periodic_timer(struct my_state *statep)
86         hrtime_t interval = CHECK_INTERVAL;
88         mutex_init(&statep->lock, NULL, MUTEX_DRIVER, DDI_IPL_0);
90         /*
91          * Register my_callback which is invoked periodically
92          * in CHECK_INTERVAL in kernel context.
93          */
94         statep->periodic_id = ddi_periodic_add(my_periodic_func,
95             statep, interval, DDI_IPL_0);
98 static void
99 my_periodic_func(void *arg)
101         /*
102          * This handler is invoked periodically.
103          */
104         struct my_state *statep = (struct my_state *)arg;
106         mutex_enter(&statep->lock);
107         if (load_unbalanced(statep)) {
108                 balance_tasks(statep);
109         }
110         mutex_exit(&statep->lock);
113 .in -2
115 .SH SEE ALSO
118 \fBcv_timedwait\fR(9F), \fBddi_intr_get_pri\fR(9F), \fBddi_periodic_add\fR(9F),
119 \fBqtimeout\fR(9F), \fBquntimeout\fR(9F), \fBtimeout\fR(9F), \fBuntimeout\fR(9F)
120 .SH NOTES
123 Historically this interface was advertised as safe for use from within the
124 periodic callback function.  In order to ensure the correct operation of the
125 system, and as reflected in the documentation above, this unlikely (and
126 unsafe) usage pattern is no longer allowed.