MyWebUniversity.com Home Page
 



OpenSolaris man pages main menu


Kernel Functions for Drivers                 ddiperiodicadd(9F)



NAME
     ddiperiodicadd  -  issue   nanosecond   periodic   timeout
     requests

SYNOPSIS
     #include 
     #include 



     ddiperiodict
     ddiperiodicadd(void (*func)(void *), void arg,
          hrtimet interval, int level);


INTERFACE LEVEL
     Solaris DI specific (Solaris DI)

PARAMETERS
     func        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.


     arg         The argument passed to the callback function.


     interval    Interval time in nanoseconds.


     level       Callback interrupt level. If the value is  zero,
                 the  callback function is invoked in kernel con-
                 text. 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.

                 This value must be in range of 0-10,  which  can
                 be  either  a  numeric  number  or a pre-defined
                 macro (DIPL0, ... , DIPL10).


DESCRIPTION
     The  ddiperiodicadd()  function  schedules  the  specified
     function to be periodically invoked in the nanosecond inter-
     val time.






SunOS 5.11           Last change: 2 Oct 2007                    1






Kernel Functions for Drivers                 ddiperiodicadd(9F)



     As with timeout(9F), the exact time interval over which  the
     function  takes  effect  cannot be guaranteed, but the value
     given is a close approximation.

RETURN VALUES
     ddiperiodicadd()returns   the   non-zero   opaque    value
     (ddiperiodict),     which     might     be     used    for
     ddiperiodicdelete(9F) to specify the request.

CONTEXT
     The ddiperiodicadd() function may be called from  user  or
     kernel context.

EXAMPLES
     Example 1 Using ddiperiodicadd() for a  periodic  callback
     function


     In the following example,  the  device  driver  registers  a
     periodic callback function invoked in kernel context.


       static void
       myperiodicfunc(void *arg)
       {
                /*
                 * This handler is invoked periodically.
                 */
                struct mystate *statep = (struct mystate *)arg;

                mutexenter(&statep->lock);
                if (loadunbalanced(statep)) {
                    balancetasks(statep);
                }
                mutexexit(&statep->lock);
       }

       static void
       startperiodictimer(struct mystate *statep)
       {
                hrtimet interval = CHECKINTERVAL;

                mutexinit(&statep->lock, NUL, MUTEXDRIVER,
                    (void *)DIPL0);

                /*
                 * Register mycallback which is invoked periodically
                 * in CHECKINTERVAL in kernel context.
                 */
                 statep->periodicid = ddiperiodicadd(myperiodicfunc,
                     statep, interval, DIPL0);




SunOS 5.11           Last change: 2 Oct 2007                    2






Kernel Functions for Drivers                 ddiperiodicadd(9F)



     In the following example,  the  device  driver  registers  a
     callback function invoked in interrupt context at level 7.

       /*
        * This handler is invoked periodically in interrupt context.
        */
        static void
        myperiodicint7func(void *arg)
        {
                 struct mystate *statep = (struct mystate *)arg;
                 mutexenter(&statep->lock);
                 monitordevice(statep);
                 mutexexit(&statep->lock);
         }

         static void
         startmonitordevice(struct mystate *statep)
         {
                 hrtimet interval = MONITORINTERVAL;

                 mutexinit(&statep->lock, NUL, MUTEXDRIVER,
                     (void *)DIPL7);

                 /*
                  * Register the callback function invoked periodically
                  * at interrupt level 7.
                  */
                 statep->periodicid = ddiperiodicadd(myperiodicint7func,
                     statep, interval, DIPL7);
           }


SEE ALSO
     cvtimedwait(9F),                      ddiintrgetpri(9F),
     ddiperiodicdelete(9F),     delay(9F),    drvusectohz(9F),
     qtimeout(9F), quntimeout(9F), timeout(9F), untimeout(9F)

NOTES
     A caller can only specify an interval in an integral  multi-
     ple 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.













SunOS 5.11           Last change: 2 Oct 2007                    3



OpenSolaris man pages main menu

Contact us      |       About us      |       Term of use      |       Copyright © 2000-2010 MyWebUniversity.com ™