*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> timeout_pending (9)              
Title
Content
Arch
Section
 

TIMEOUT(9)

Contents


NAME    [Toc]    [Back]

     timeout_set, timeout_add, timeout_del, timeout_pending,
     timeout_initialized - execute a function after  a  specified
period of time

SYNOPSIS    [Toc]    [Back]

     #include <sys/types.h>
     #include <sys/timeout.h>

     void
     timeout_set(struct  timeout  *to,  void  (*fn)(void *), void
*arg);

     void
     timeout_add(struct timeout *to, int ticks);

     void
     timeout_del(struct timeout *to);

     int
     timeout_pending(struct timeout *to);

     int
     timeout_initialized(struct timeout *to);

     int
     timeout_triggered(struct timeout *to);

DESCRIPTION    [Toc]    [Back]

     The timeout API provides a mechanism to execute  a  function
at a given
     time.   The granularity of the time is limited by the granularity of the
     hardclock(9) timer which executes hz(9) times a second.  The
function
     will be called at softclock interrupt level.

     It  is  the  responsibility  of  the caller to provide these
functions with
     pre-allocated timeout structures.  All functions in this API
may be used
     in interrupt context below splclock().

     This  API  replaces  the  historic  functions  timeout() and
untimeout().

     The function timeout_set() prepares the timeout structure to
to be used
     in  future  calls  to  timeout_add() and timeout_del().  The
timeout will be
     prepared to call the function specified by the  fn  argument
with a void *
     argument  given  in the arg argument.  Once initialized, the
to structure
     can be used repeatedly in  timeout_add()  and  timeout_del()
and does not
     need  to  be reinitialized unless the function called and/or
its argument
     must change.

     The function timeout_add() schedules the execution of the to
timeout in
     at least ticks/hz seconds.  Negative values of ticks are illegal.  If the
     value is `0' it will,  in  the  current  implementation,  be
treated as `1',
     but  in the future it might cause an immediate timeout.  The
timeout in
     the to argument must be already initialized by timeout_set()
and may not
     be  used in calls to timeout_set() until it has timed out or
been removed
     with timeout_del().  If the timeout in the  to  argument  is
already scheduled,
  the  old  execution  time will be replaced by the new
one.

     The function timeout_del() will cancel the  timeout  in  the
argument to.
     If  the timeout has already executed or has never been added
the call will
     have no effect.

     The timeout_pending() macro can be used to check if a  timeout is scheduled
 to run.

     The  timeout_initialized()  macro  can be used to check if a
timeout has
     been initialized.

     The timeout_triggered() macro can be  used  to  check  if  a
timeout is running
  or  has been run.  The timeout_add() and timeout_del()
functions
     clear the triggered state for that timeout.

CODE REFERENCES    [Toc]    [Back]

     These   functions    are    implemented    in    the    file
sys/kern/kern_timeout.c.

SEE ALSO    [Toc]    [Back]

      
      
     hz(9), hzto(9), sleep(9), splclock(9), tvtohz(9)

OpenBSD      3.6                           June      23,     1996
[ Back ]
 Similar pages
Name OS Title
timeout FreeBSD execute a function after a specified length of time
callout_reset FreeBSD execute a function after a specified length of time
callout_init FreeBSD execute a function after a specified length of time
callout_stop FreeBSD execute a function after a specified length of time
untimeout FreeBSD execute a function after a specified length of time
callout NetBSD execute a function after a specified length of time
callout_stop NetBSD execute a function after a specified length of time
callout_init NetBSD execute a function after a specified length of time
untimeout NetBSD execute a function after a specified length of time
callout_deactivate NetBSD execute a function after a specified length of time
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service