⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timerlib.html

📁 Vxworks API操作系统和驱动程序设计API。压缩的HTML文件
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/timerLib.html - generated by refgen from timerLib.c --> <title> timerLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.htm"><i>VxWorks API Reference :  OS Libraries</i></a></p></blockquote><h1>timerLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>timerLib</strong> - timer library (POSIX) </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./timerLib.html#timer_cancel">timer_cancel</a>(&nbsp;)</b>  -  cancel a timer<br><b><a href="./timerLib.html#timer_connect">timer_connect</a>(&nbsp;)</b>  -  connect a user routine to the timer signal<br><b><a href="./timerLib.html#timer_create">timer_create</a>(&nbsp;)</b>  -  allocate a timer using the specified clock for a timing base (POSIX)<br><b><a href="./timerLib.html#timer_delete">timer_delete</a>(&nbsp;)</b>  -  remove a previously created timer (POSIX)<br><b><a href="./timerLib.html#timer_gettime">timer_gettime</a>(&nbsp;)</b>  -  get the remaining time before expiration and the reload value (POSIX)<br><b><a href="./timerLib.html#timer_getoverrun">timer_getoverrun</a>(&nbsp;)</b>  -  return the timer expiration overrun (POSIX)<br><b><a href="./timerLib.html#timer_settime">timer_settime</a>(&nbsp;)</b>  -  set the time until the next expiration and arm timer (POSIX)<br><b><a href="./timerLib.html#nanosleep">nanosleep</a>(&nbsp;)</b>  -  suspend the current task until the time interval elapses (POSIX)<br><b><a href="./timerLib.html#sleep">sleep</a>(&nbsp;)</b>  -  delay for a specified amount of time<br><b><a href="./timerLib.html#alarm">alarm</a>(&nbsp;)</b>  -  set an alarm clock for delivery of a signal<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides a timer interface, as defined in the IEEE standard,POSIX 1003.1b.<p>Timers are mechanisms by which tasks signal themselves after a designatedinterval.  Timers are built on top of the clock and signal facilities.  Theclock facility provides an absolute time-base.  Standard timer functionssimply consist of creation, deletion and setting of a timer.  When a timerexpires, <b><a href="./sigLib.html#sigaction">sigaction</a>(&nbsp;)</b> (see <b><a href="./sigLib.html#top">sigLib</a></b>) must be in place in order for the userto handle the event.  The "high resolution sleep" facility, <b><a href="./timerLib.html#nanosleep">nanosleep</a>(&nbsp;)</b>,allows sub-second sleeping to the resolution of the clock.<p>The <b><a href="./clockLib.html#top">clockLib</a></b> library should be installed and <b><a href="./clockLib.html#clock_settime">clock_settime</a>(&nbsp;)</b> setbefore the use of any timer routines.<p></blockquote><h4>ADDITIONS</h4><blockquote><p>Two non-POSIX functions are provided for user convenience:<p>&nbsp;&nbsp;&nbsp;&nbsp;<b><a href="./timerLib.html#timer_cancel">timer_cancel</a>(&nbsp;)</b>&nbsp;quickly&nbsp;disables&nbsp;a&nbsp;timer&nbsp;by&nbsp;calling&nbsp;<b><a href="./timerLib.html#timer_settime">timer_settime</a>(&nbsp;)</b>.<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><a href="./timerLib.html#timer_connect">timer_connect</a>(&nbsp;)</b>&nbsp;easily&nbsp;hooks&nbsp;up&nbsp;a&nbsp;user&nbsp;routine&nbsp;by&nbsp;calling&nbsp;<b><a href="./sigLib.html#sigaction">sigaction</a>(&nbsp;)</b>.<p></blockquote><h4>CLARIFICATIONS</h4><blockquote><p>The task creating a timer with <b><a href="./timerLib.html#timer_create">timer_create</a>(&nbsp;)</b> will receive thesignal no matter which task actually arms the timer.<p>When a timer expires and the task has previously exited, <b><a href="./logLib.html#logMsg">logMsg</a>(&nbsp;)</b>indicates the expected task is not present.  Similarly, <b><a href="./logLib.html#logMsg">logMsg</a>(&nbsp;)</b> indicateswhen a task arms a timer without installing a signal handler.  Timers maybe armed but not created or deleted at interrupt level.<p></blockquote><h4>IMPLEMENTATION</h4><blockquote><p>The actual clock resolution is hardware-specific and in many cases is1/60th of a second.  This is less than <b>_POSIX_CLOCKRES_MIN</b>, which isdefined as 20 milliseconds (1/50th of a second).<p></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>timers.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./clockLib.html#top">clockLib</a></b>, <b><a href="./sigLib.html#sigaction">sigaction</a>(&nbsp;)</b>, POSIX 1003.1b documentation,<i>VxWorks Programmer's Guide: Basic\ OS </i><hr><a name="timer_cancel"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>timer_cancel(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>timer_cancel(&nbsp;)</strong> - cancel a timer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int timer_cancel    (    timer_t timerid           /* timer ID */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine is a shorthand method of invoking <b><a href="./timerLib.html#timer_settime">timer_settime</a>(&nbsp;)</b>, which stopsa timer.<p></blockquote><h4>NOTE</h4><blockquote><p>Non-POSIX.<p></blockquote><h4>RETURNS</h4><blockquote><p>0 (OK), or -1 (ERROR) if <i>timerid</i> is invalid.<p></blockquote><h4>ERRNO</h4><blockquote><p>EINVAL</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./timerLib.html#top">timerLib</a></b><hr><a name="timer_connect"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>timer_connect(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>timer_connect(&nbsp;)</strong> - connect a user routine to the timer signal</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int timer_connect    (    timer_t     timerid,      /* timer ID */    VOIDFUNCPTR routine,      /* user routine */    int         arg           /* user argument */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine sets the specified <i>routine</i> to be invoked with <i>arg</i> whenfielding a signal indicated by the timer's <i>evp</i> signal number, orif <i>evp</i> is NULL, when fielding the default signal (SIGALRM).<p>The signal handling routine should be declared as:<p><pre>    void my_handler        (        timer_t timerid,      /* expired timer ID */        int arg               /* user argument    */        )</pre></blockquote><h4>NOTE</h4><blockquote><p>Non-POSIX.<p></blockquote><h4>RETURNS</h4><blockquote><p>0 (OK), or -1 (ERROR) if the timer is invalid or cannot bind the signal handler.<p></blockquote><h4>ERRNO</h4><blockquote><p>EINVAL</blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./timerLib.html#top">timerLib</a></b><hr><a name="timer_create"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>timer_create(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>timer_create(&nbsp;)</strong> - allocate a timer using the specified clock for a timing base (POSIX)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int timer_create    (    clockid_t         clock_id, /* clock ID (always CLOCK_REALTIME) */    struct sigevent * evp,      /* user event handler */    timer_t *         pTimer    /* ptr to return value */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine returns a value in <i>pTimer</i> that identifies the timer in subsequent timer requests.  The <i>evp</i> argument, if non-NULL, points to a <b>sigevent</b> structure, which is allocated by the application and defines the signal number and application-specific data to be sent to the task when the timer expires.  If <i>evp</i> is NULL, a default signal (SIGALRM) is queued to the task, and the signal data is set to the timer ID.  Initially, the timer is disarmed.<p></blockquote><h4>RETURNS</h4><blockquote><p><p>0 (OK), or -1 (ERROR) if too many timers already are allocated or the signal number is invalid.<p></blockquote><h4>ERRNO</h4><blockquote><p>EMTIMERS, EINVAL, ENOSYS, EAGAIN, <b>S_memLib_NOT_ENOUGH_MEMORY</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./timerLib.html#top">timerLib</a></b>, <b><a href="./timerLib.html#timer_delete">timer_delete</a>(&nbsp;)</b><hr><a name="timer_delete"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>timer_delete(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>timer_delete(&nbsp;)</strong> - remove a previously created timer (POSIX)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int timer_delete    (    timer_t timerid           /* timer ID */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine removes a timer.<p></blockquote><h4>RETURNS</h4><blockquote><p>0 (OK), or -1 (ERROR) if <i>timerid</i> is invalid.<p></blockquote><h4>ERRNO</h4><blockquote><p>EINVAL<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./timerLib.html#top">timerLib</a></b>, <b><a href="./timerLib.html#timer_create">timer_create</a>(&nbsp;)</b><hr><a name="timer_gettime"></a><p align=right><a href="rtnIndex.htm"><i>OS Libraries :  Routines</i></a></p></blockquote><h1>timer_gettime(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>timer_gettime(&nbsp;)</strong> - get the remaining time before expiration and the reload value (POSIX)</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>int timer_gettime    (    timer_t             timerid, /* timer ID */    struct itimerspec * value    /* where to return remaining time */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine gets the remaining time and reload value of a specified timer.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -