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

📄 c-basic6.html

📁 this about vxworks operations systems
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>     Basic OS   </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-basic.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-basic5.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-basic7.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="86844">2.6  &nbsp;&nbsp;Watchdog Timers</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86845"> </a>VxWorks includes a watchdog-timer mechanism that allows any C function to be connected to a specified time delay. Watchdog timers are maintained as part of the system clock ISR. Normally, functions invoked by watchdog timers execute as interrupt service code at the interrupt level of the system clock. However, if the kernel is unable to execute the function immediately for any reason (such as a previous interrupt or kernel state), the function is placed on the <b class="task">tExcTask</b> work queue. Functions on the <b class="task">tExcTask</b> work queue execute at the priority level of the <b class="task">tExcTask</b> (usually 0). Restrictions on ISRs apply to routines connected to watchdog timers. The functions in <a href="c-basic6.html#86852">Table&nbsp;2-24</a> are provided by the <b class="library">wdLib</b> library.<p class="table"><h4 class="EntityTitle"><a name="86852"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 2-24:&nbsp;&nbsp;Watchdog Timer Calls</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86856"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Call</font></b></div></th><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86858"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86865"> </a><b class="routine"><i class="routine">wdCreate</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86867"> </a>Allocate and initialize a watchdog timer.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86870"> </a><b class="routine"><i class="routine">wdDelete</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86872"> </a>Terminate and deallocate a watchdog timer.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86875"> </a><b class="routine"><i class="routine">wdStart</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86877"> </a>Start a watchdog timer.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86880"> </a><b class="routine"><i class="routine">wdCancel</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86882"> </a>Cancel a currently counting watchdog timer.&nbsp;</div></td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p><dd><p class="Body"><a name="86888"> </a>A watchdog timer is first created by calling <b class="routine"><i class="routine">wdCreate</i></b><b>(&nbsp;)</b>. Then the timer can be started by calling <b class="routine"><i class="routine">wdStart</i></b><b>(&nbsp;)</b>, which takes as arguments the number of ticks to delay, the C function to call, and an argument to be passed to that function. After the specified number of ticks have elapsed, the function is called with the specified argument. The watchdog timer can be canceled any time before the delay has elapsed by calling <b class="routine"><i class="routine">wdCancel</i></b><b>(&nbsp;)</b>.</p></dl></dl><h4 class="EntityTitle"><a name="86892"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 2-12:&nbsp;&nbsp;Watchdog Timers </font></a></h4><dl class="margin"><dl class="margin"><dd><pre class="Code"><b><a name="86893">/* This example creates a watchdog timer and sets it to go off in &nbsp;* 3 seconds. &nbsp;*/</a></b><dd> <b><a name="86895">/* includes */ #include&nbsp;"vxWorks.h" #include&nbsp;"logLib.h" #include&nbsp;"wdLib.h"</a></b><dd> <b><a name="86897">/* defines */ #define&nbsp;&nbsp;SECONDS (3)</a></b><dd> <b><a name="86899">WDOG_ID myWatchDogId; task (void)     {     /* Create watchdog */</a></b><dd> <b><a name="93204">    if ((myWatchDogId = wdCreate( )) == NULL)         return (ERROR);</a></b><dd> <b><a name="93205">    /* Set timer to go off in SECONDS - printing a message to stdout */</a></b><dd> <b><a name="86907">    if (wdStart (myWatchDogId, sysClkRateGet( ) * SECONDS, logMsg,      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Watchdog timer just expired\n") == ERROR)         return (ERROR);</a></b><dd> <b><a name="86912">    /* ... */     }</a></b></pre></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-basic.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-basic5.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-basic7.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc.    conversion tool:  Quadralay WebWorks Publisher 4.0.11    template:         CSS Template, Jan 1998 - Jefro --->

⌨️ 快捷键说明

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