Print this page
OS-2366 ddi_periodic_add(9F) is entirely rubbish

@@ -1,13 +1,14 @@
 '\" te
 .\"  Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright 2013, Joyent, Inc. All Rights Reserved.
 .\" 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.
 .\"  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
 .\" the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH DDI_PERIODIC_ADD 9F "Apr 13, 2009"
+.TH DDI_PERIODIC_ADD 9F "Jul 23, 2013"
 .SH NAME
-ddi_periodic_add \- issue nanosecond periodic timeout requests
+ddi_periodic_add \- request periodic function invocation
 .SH SYNOPSIS
 .LP
 .nf
 #include <sys/dditypes.h>
 #include <sys/sunddi.h>

@@ -25,13 +26,11 @@
 .ne 2
 .na
 \fB\fIfunc\fR\fR
 .ad
 .RS 12n
-The callback function is invoked periodically in the specified interval. If the
-argument level is zero, the function is invoked in kernel context. Otherwise,
-it's invoked in interrupt context at the specified level.
+The callback function to be invoked periodically in the specified interval.
 .RE
 
 .sp
 .ne 2
 .na

@@ -45,25 +44,26 @@
 .ne 2
 .na
 \fB\fIinterval\fR\fR
 .ad
 .RS 12n
-Interval time in nanoseconds.
+The periodic interval time in nanoseconds.
 .RE
 
 .sp
 .ne 2
 .na
 \fB\fIlevel\fR\fR
 .ad
 .RS 12n
-Callback interrupt level. If the value is zero, the callback function is
-invoked in kernel context. If the value is more than zero, but less than or
-equal to ten, the callback function is invoked in interrupt context at the
-specified interrupt level, which may be used for real time applications.
+The callback function is invoked at this priority level.  If the value of
+\fIlevel\fR is zero, the callback function is invoked in kernel context.
+If the value is greater than zero, but less than or equal to ten, the callback
+function is invoked in interrupt context at the specified interrupt level,
+which may be used for real time applications.
 .sp
-This value must be in range of 0-10, which can be either a numeric number, a
+This value must be in range of 0-10, which can be either an integer literal, a
 pre-defined macro (\fBDDI_IPL_0\fR, ... , \fBDDI_IPL_10\fR), or the
 \fBDDI_INTR_PRI\fR macro with the interrupt priority.
 .RE
 
 .SH DESCRIPTION

@@ -73,17 +73,19 @@
 periodically invoked in the nanosecond interval time.
 .sp
 .LP
 As with \fBtimeout\fR(9F), the exact time interval over which the function
 takes effect cannot be guaranteed, but the value given is a close
-approximation.
+approximation.  If the callback function has not finished execution when the
+next interval expires, the system will skip running the callback for that
+interval.
 .SH RETURN VALUES
 .sp
 .LP
-\fBddi_periodic_add()\fRreturns the non-zero opaque value
-(\fBddi_periodic_t\fR), which might be used for \fBddi_periodic_delete\fR(9F)
-to specify the request.
+\fBddi_periodic_add()\fR returns the non-zero opaque value
+(\fBddi_periodic_t\fR), which is later used to cancel the periodic request
+with \fBddi_periodic_delete\fR(9F).
 .SH CONTEXT
 .sp
 .LP
 The \fBddi_periodic_add()\fR function may be called from user or kernel
 context.

@@ -116,12 +118,11 @@
 static void
 start_periodic_timer(struct my_state *statep)
 {
          hrtime_t interval = CHECK_INTERVAL;
 
-         mutex_init(&statep->lock, NULL, MUTEX_DRIVER,
-             (void *)DDI_IPL_0);
+         mutex_init(&statep->lock, NULL, MUTEX_DRIVER, DDI_IPL_0);
 
          /*
           * Register my_callback which is invoked periodically
           * in CHECK_INTERVAL in kernel context.
           */

@@ -152,12 +153,11 @@
   static void
   start_monitor_device(struct my_state *statep)
   {
           hrtime_t interval = MONITOR_INTERVAL;
 
-          mutex_init(&statep->lock, NULL, MUTEX_DRIVER,
-              (void *)DDI_IPL_7);
+          mutex_init(&statep->lock, NULL, MUTEX_DRIVER, DDI_IPL_7);
 
           /*
            * Register the callback function invoked periodically
            * at interrupt level 7.
            */

@@ -170,13 +170,12 @@
 .SH SEE ALSO
 .sp
 .LP
 \fBcv_timedwait\fR(9F), \fBddi_intr_get_pri\fR(9F),
 \fBddi_periodic_delete\fR(9F), \fBddi_intr_get_softint_pri\fR(9F),
-\fBdelay\fR(9F), \fBdrv_usectohz\fR(9F), \fBqtimeout\fR(9F),
-\fBquntimeout\fR(9F), \fBtimeout\fR(9F), \fBuntimeout\fR(9F)
+\fBqtimeout\fR(9F), \fBquntimeout\fR(9F), \fBtimeout\fR(9F), \fBuntimeout\fR(9F)
 .SH NOTES
 .sp
 .LP
-A caller can only specify an interval in an integral multiple of 10ms. No other
-values are supported at this time. The interval specified is a lower bound on
-the interval on which the callback occurs.
+The caller must specify \fIinterval\fR as an even, non-zero multiple of 10ms.
+No other values are supported at this time. The interval specified is a lower
+bound on the interval between executions of the callback.