📄 timerlib.html
字号:
<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>( )</b> - cancel a timer<br><b><a href="./timerLib.html#timer_connect">timer_connect</a>( )</b> - connect a user routine to the timer signal<br><b><a href="./timerLib.html#timer_create">timer_create</a>( )</b> - allocate a timer using the specified clock for a timing base (POSIX)<br><b><a href="./timerLib.html#timer_delete">timer_delete</a>( )</b> - remove a previously created timer (POSIX)<br><b><a href="./timerLib.html#timer_gettime">timer_gettime</a>( )</b> - get the remaining time before expiration and the reload value (POSIX)<br><b><a href="./timerLib.html#timer_getoverrun">timer_getoverrun</a>( )</b> - return the timer expiration overrun (POSIX)<br><b><a href="./timerLib.html#timer_settime">timer_settime</a>( )</b> - set the time until the next expiration and arm timer (POSIX)<br><b><a href="./timerLib.html#nanosleep">nanosleep</a>( )</b> - suspend the current task until the time interval elapses (POSIX)<br><b><a href="./timerLib.html#sleep">sleep</a>( )</b> - delay for a specified amount of time<br><b><a href="./timerLib.html#alarm">alarm</a>( )</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>( )</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>( )</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>( )</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> <b><a href="./timerLib.html#timer_cancel">timer_cancel</a>( )</b> quickly disables a timer by calling <b><a href="./timerLib.html#timer_settime">timer_settime</a>( )</b>.<br> <b><a href="./timerLib.html#timer_connect">timer_connect</a>( )</b> easily hooks up a user routine by calling <b><a href="./sigLib.html#sigaction">sigaction</a>( )</b>.<p></blockquote><h4>CLARIFICATIONS</h4><blockquote><p>The task creating a timer with <b><a href="./timerLib.html#timer_create">timer_create</a>( )</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>( )</b>indicates the expected task is not present. Similarly, <b><a href="./logLib.html#logMsg">logMsg</a>( )</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>( )</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( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>timer_cancel( )</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>( )</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( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>timer_connect( )</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( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>timer_create( )</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>( )</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( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>timer_delete( )</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>( )</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( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>timer_gettime( )</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 + -