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

📄 siglib.html

📁 Vxworks API操作系统和驱动程序设计API。压缩的HTML文件
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/sigLib.html - generated by refgen from sigLib.c --> <title> sigLib </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>sigLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>sigLib</strong> - software signal facility library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><a href="./sigLib.html#sigInit">sigInit</a>(&nbsp;)</b>  -  initialize the signal facilities<br><b><a href="./sigLib.html#sigqueueInit">sigqueueInit</a>(&nbsp;)</b>  -  initialize the queued signal facilities<br><b><a href="./sigLib.html#sigemptyset">sigemptyset</a>(&nbsp;)</b>  -  initialize a signal set with no signals included (POSIX)<br><b><a href="./sigLib.html#sigfillset">sigfillset</a>(&nbsp;)</b>  -  initialize a signal set with all signals included (POSIX)<br><b><a href="./sigLib.html#sigaddset">sigaddset</a>(&nbsp;)</b>  -  add a signal to a signal set (POSIX)<br><b><a href="./sigLib.html#sigdelset">sigdelset</a>(&nbsp;)</b>  -  delete a signal from a signal set (POSIX)<br><b><a href="./sigLib.html#sigismember">sigismember</a>(&nbsp;)</b>  -  test to see if a signal is in a signal set (POSIX)<br><b><a href="./sigLib.html#signal">signal</a>(&nbsp;)</b>  -  specify the handler associated with a signal<br><b><a href="./sigLib.html#sigaction">sigaction</a>(&nbsp;)</b>  -  examine and/or specify the action associated with a signal (POSIX)<br><b><a href="./sigLib.html#sigprocmask">sigprocmask</a>(&nbsp;)</b>  -  examine and/or change the signal mask (POSIX)<br><b><a href="./sigLib.html#sigpending">sigpending</a>(&nbsp;)</b>  -  retrieve the set of pending signals blocked from delivery (POSIX)<br><b><a href="./sigLib.html#sigsuspend">sigsuspend</a>(&nbsp;)</b>  -  suspend the task until delivery of a signal (POSIX)<br><b><a href="./sigLib.html#pause">pause</a>(&nbsp;)</b>  -  suspend the task until delivery of a signal (POSIX)<br><b><a href="./sigLib.html#sigtimedwait">sigtimedwait</a>(&nbsp;)</b>  -  wait for a signal<br><b><a href="./sigLib.html#sigwaitinfo">sigwaitinfo</a>(&nbsp;)</b>  -  wait for real-time signals<br><b><a href="./sigLib.html#sigwait">sigwait</a>(&nbsp;)</b>  -  wait for a signal to be delivered (POSIX)<br><b><a href="./sigLib.html#sigvec">sigvec</a>(&nbsp;)</b>  -  install a signal handler<br><b><a href="./sigLib.html#sigsetmask">sigsetmask</a>(&nbsp;)</b>  -  set the signal mask<br><b><a href="./sigLib.html#sigblock">sigblock</a>(&nbsp;)</b>  -  add to a set of blocked signals<br><b><a href="./sigLib.html#raise">raise</a>(&nbsp;)</b>  -  send a signal to the caller's task<br><b><a href="./sigLib.html#kill">kill</a>(&nbsp;)</b>  -  send a signal to a task (POSIX)<br><b><a href="./sigLib.html#sigqueue">sigqueue</a>(&nbsp;)</b>  -  send a queued signal to a task<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides a signal interface for tasks.  Signals are used toalter the flow control of tasks by communicating asynchronous eventswithin or between task contexts.  Any task or interrupt service can"raise" (or send) a signal to a particular task.  The task being signaledwill immediately suspend its current thread of execution and invoke atask-specified "signal handler" routine.  The signal handler is auser-supplied routine that is bound to a specific signal and performswhatever actions are necessary whenever the signal is received.  Signalsare most appropriate for error and exception handling, rather than as ageneral purpose intertask communication mechanism.<p>This library has both a BSD 4.3 and POSIX signal interface.  The POSIXinterface provides a standardized interface which is more functional thanthe traditional BSD 4.3 interface.  The chart below shows the correlationbetween BSD 4.3 and POSIX 1003.1 functions.  An application should use only oneform of interface and not intermix them.<p><table><tr valign=top><th align=left></tr><tr valign=top><th align=left>BSD 4.3    </th><th align=left> POSIX 1003.1</tr><tr><td colspan="3"><hr></tr><tr valign=top><td align=left><b>sigmask(&nbsp;)</b>    </td><td align=left> <b><a href="./sigLib.html#sigemptyset">sigemptyset</a>(&nbsp;)</b>, <b><a href="./sigLib.html#sigfillset">sigfillset</a>(&nbsp;)</b>, <b><a href="./sigLib.html#sigaddset">sigaddset</a>(&nbsp;)</b>,</tr><tr valign=top><td align=left> </td><td align=left>      </td><td align=left>    <b><a href="./sigLib.html#sigdelset">sigdelset</a>(&nbsp;)</b>, <b><a href="./sigLib.html#sigismember">sigismember</a>(&nbsp;)</b></tr><tr valign=top><td align=left><b><a href="./sigLib.html#sigblock">sigblock</a>(&nbsp;)</b>   </td><td align=left> <b><a href="./sigLib.html#sigprocmask">sigprocmask</a>(&nbsp;)</b></tr><tr valign=top><td align=left><b><a href="./sigLib.html#sigsetmask">sigsetmask</a>(&nbsp;)</b> </td><td align=left> <b><a href="./sigLib.html#sigprocmask">sigprocmask</a>(&nbsp;)</b></tr><tr valign=top><td align=left><b><a href="./sigLib.html#pause">pause</a>(&nbsp;)</b>      </td><td align=left> <b><a href="./sigLib.html#sigsuspend">sigsuspend</a>(&nbsp;)</b></tr><tr valign=top><td align=left><b><a href="./sigLib.html#sigvec">sigvec</a>(&nbsp;)</b>     </td><td align=left> <b><a href="./sigLib.html#sigaction">sigaction</a>(&nbsp;)</b></tr><tr valign=top><td align=left>(none)       </td><td align=left> <b><a href="./sigLib.html#sigpending">sigpending</a>(&nbsp;)</b></tr><tr valign=top><td align=left><b><a href="./sigLib.html#signal">signal</a>(&nbsp;)</b>     </td><td align=left> <b><a href="./sigLib.html#signal">signal</a>(&nbsp;)</b></tr><tr valign=top><td align=left><b><a href="./sigLib.html#kill">kill</a>(&nbsp;)</b>       </td><td align=left> <b><a href="./sigLib.html#kill">kill</a>(&nbsp;)</b></tr><tr valign=top><td align=left></tr></tr></table>POSIX 1003.1b (Real-Time Extensions) also specifies a queued-signalfacility that involves four additional routines: <b><a href="./sigLib.html#sigqueue">sigqueue</a>(&nbsp;)</b>,<b><a href="./sigLib.html#sigwaitinfo">sigwaitinfo</a>(&nbsp;)</b>, and <b><a href="./sigLib.html#sigtimedwait">sigtimedwait</a>(&nbsp;)</b>.<p>In many ways, signals are analogous to hardware interrupts.  The signalfacility provides a set of 31 distinct signals.  A signal can be raised bycalling <b><a href="./sigLib.html#kill">kill</a>(&nbsp;)</b>, which is analogous to an interrupt or hardware exception.A signal handler is bound to a particular signal with <b><a href="./sigLib.html#sigaction">sigaction</a>(&nbsp;)</b> in muchthe same way that an interrupt service routine is connected to aninterrupt vector with <b><a href="./intArchLib.html#intConnect">intConnect</a>(&nbsp;)</b>.  Signals are blocked for the durationof the signal handler, just as interrupts are locked out for the durationof the interrupt service routine.  Tasks can block the occurrence ofcertain signals with <b><a href="./sigLib.html#sigprocmask">sigprocmask</a>(&nbsp;)</b>, just as the interrupt level can beraised or lowered to block out levels of interrupts.  If a signal isblocked when it is raised, its handler routine will be called when thesignal becomes unblocked.<p>Several routines (<b><a href="./sigLib.html#sigprocmask">sigprocmask</a>(&nbsp;)</b>, <b><a href="./sigLib.html#sigpending">sigpending</a>(&nbsp;)</b>, and <b><a href="./sigLib.html#sigsuspend">sigsuspend</a>(&nbsp;)</b>) take <b>sigset_t</b> data structures as parameters.  These data structures are used to specify signal set masks.  Several routines are provided for manipulating these data structures: <b><a href="./sigLib.html#sigemptyset">sigemptyset</a>(&nbsp;)</b> clears all the bits in a <b>segset_t</b>,  <b><a href="./sigLib.html#sigfillset">sigfillset</a>(&nbsp;)</b> sets all the bits in a <b>sigset_t</b>, <b><a href="./sigLib.html#sigaddset">sigaddset</a>(&nbsp;)</b> sets the bit in a <b>sigset_t</b> corresponding to a particular signal number, <b><a href="./sigLib.html#sigdelset">sigdelset</a>(&nbsp;)</b> resets the bit in a <b>sigset_t</b> corresponding to a particular signal number, and <b><a href="./sigLib.html#sigismember">sigismember</a>(&nbsp;)</b> tests to see if the bit corresponding to a particular signal number is set.<p></blockquote><h4>FUNCTION RESTARTING</h4><blockquote><p>If a task is pended (for instance, by waiting for a semaphore to becomeavailable) and a signal is sent to the task for which the task has ahandler installed, then the handler will run before the semaphore istaken.  When the handler is done, the task will go back to being pended(waiting for the semaphore).  If there was a timeout used for the pend,then the original value will be used again when the task returns from thesignal handler and goes back to being pended.<p>Signal handlers are typically defined as:<p><pre>    void sigHandler        (        int sig,                        /* signal number                 */        )        {            ...        }</pre>In VxWorks, the signal handler is passed additional arguments and can bedefined as:<p><pre>    void sigHandler        (        int sig,                        /* signal number                 */        int code,                       /* additional code               */        struct sigcontext *pSigContext  /* context of task before signal */        )        {            ...        }</pre>The parameter <i>code</i> is valid only for signals caused by hardwareexceptions.  In this case, it is used to distinguish signal variants.For example, both numeric overflow and zero divide raise SIGFPE(floating-point exception) but have different values for <i>code</i>.(Note that when the above VxWorks extensions are used, the compilermay issue warnings.)<p></blockquote><h4>SIGNAL HANDLER DEFINITION</h4><blockquote><p>Signal handling routines must follow one of two specific formats, so that theymay be correctly called by the operating system when a signal occurs.  <p>Traditional signal handlers receive the signal number as the sole input parameter.  However, certain signals generated by routines which make up thePOSIX Real-Time Extensions (P1003.1b) support the passing of an additionalapplication-specific value to the handler routine.  These include signalsgenerated by the <b><a href="./sigLib.html#sigqueue">sigqueue</a>(&nbsp;)</b> call, by asynchronous I/O, by POSIX real-timetimers, and by POSIX message queues.<p>If a signal handler routine is to receive these additional parameters,<b>SA_SIGINFO</b> must be set in the <b>sa_flags</b> field of the sigaction structure whichis a parameter to the <b><a href="./sigLib.html#sigaction">sigaction</a>(&nbsp;)</b> routine.  Such routines must take thefollowing form:<p><pre>        void sigHandler (int sigNum, siginfo_t * pInfo, void * pContext);</pre>Traditional signal handling routines must not set <b>SA_SIGINFO</b> in the <b>sa_flags</b>field, and must take the form of:<p><pre>        void sigHandler (int sigNum);</pre></blockquote><h4>EXCEPTION PROCESSING</h4><blockquote><p><p>Certain signals, defined below, are raised automatically whenhardware exceptions are encountered.  This mechanism allows user-definedexception handlers to be installed.  This is useful for recovering fromcatastrophic events such as bus or arithmetic errors.  Typically, <b><a href="./ansiSetjmp.html#setjmp">setjmp</a>(&nbsp;)</b>is called to define the point in the program where control will berestored, and <b><a href="./ansiSetjmp.html#longjmp">longjmp</a>(&nbsp;)</b> is called in the signal handler to restore thatcontext.  Note that <b><a href="./ansiSetjmp.html#longjmp">longjmp</a>(&nbsp;)</b> restores the state of the task's signalmask.  If a user-defined handler is not installed or the installed handlerreturns for a signal raised by a hardware exception, then the task issuspended and a message is logged to the console.<p>The following is a list of hardware exceptions caught by VxWorks and deliveredto the offending task.  The user may include the higher-level header file<b>sigCodes.h</b> in order to access the appropriate architecture-specific header filecontaining the code value.</blockQuote><h4>Motorola 68K</h4><blockQuote><table><tr valign=top><th align=left>Signal  </th><th align=left> Code               </th><th align=left> Exception</tr><tr><td colspan="3"><hr></tr><tr valign=top><td align=left>SIGSEGV </td><td align=left> NULL               </td><td align=left> bus error</tr><tr valign=top><td align=left>SIGBUS  </td><td align=left> <b>BUS_ADDERR</b>         </td><td align=left> address error</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_ILLINSTR_FAULT</b> </td><td align=left> illegal instruction</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_INTDIV_TRAP</b>    </td><td align=left> zero divide</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_CHKINST_TRAP</b>   </td><td align=left> chk trap</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_TRAPV_TRAP</b>     </td><td align=left> trapv trap</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_PRIVVIO_FAULT</b>  </td><td align=left> privilege violation</tr><tr valign=top><td align=left>SIGTRAP </td><td align=left> NULL               </td><td align=left> trace exception</tr><tr valign=top><td align=left>SIGEMT  </td><td align=left> <b>EMT_EMU1010</b>        </td><td align=left> line 1010 emulator</tr><tr valign=top><td align=left>SIGEMT  </td><td align=left> <b>EMT_EMU1111</b>        </td><td align=left> line 1111 emulator</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_ILLINSTR_FAULT</b> </td><td align=left> coprocessor protocol violation</tr><tr valign=top><td align=left>SIGFMT  </td><td align=left> NULL               </td><td align=left> format error</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_FLTBSUN_TRAP</b>   </td><td align=left> compare unordered</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_FLTINEX_TRAP</b>   </td><td align=left> inexact result</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_FLTDIV_TRAP</b>    </td><td align=left> divide by zero</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_FLTUND_TRAP</b>    </td><td align=left> underflow</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_FLTOPERR_TRAP</b>  </td><td align=left> operand error</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_FLTOVF_TRAP</b>    </td><td align=left> overflow</tr><tr valign=top><td align=left>SIGFPE  </td><td align=left> <b>FPE_FLTNAN_TRAP</b>    </td><td align=left> signaling "Not A Number"</tr><tr valign=top><td align=left></tr></tr></table></blockQuote><h4>SPARC</h4><blockQuote><table><tr valign=top><th align=left>Signal </th><th align=left> Code                </th><th align=left> Exception</tr><tr><td colspan="3"><hr></tr><tr valign=top><td align=left>SIGBUS </td><td align=left> <b>BUS_INSTR_ACCESS</b>    </td><td align=left> bus error on instruction fetch</tr><tr valign=top><td align=left>SIGBUS </td><td align=left> <b>BUS_ALIGN</b>           </td><td align=left> address error (bad alignment)</tr><tr valign=top><td align=left>SIGBUS </td><td align=left> <b>BUS_DATA_ACCESS</b>     </td><td align=left> bus error on data access</tr><tr valign=top><td align=left>SIGILL </td><td align=left> <b>ILL_ILLINSTR_FAULT</b>  </td><td align=left> illegal instruction</tr><tr valign=top><td align=left>SIGILL </td><td align=left> <b>ILL_PRIVINSTR_FAULT</b> </td><td align=left> privilege violation</tr><tr valign=top><td align=left>SIGILL </td><td align=left> <b>ILL_COPROC_DISABLED</b> </td><td align=left> coprocessor disabled</tr><tr valign=top><td align=left>SIGILL </td><td align=left> <b>ILL_COPROC_EXCPTN</b>   </td><td align=left> coprocessor exception</tr><tr valign=top><td align=left>SIGILL </td><td align=left> <b>ILL_TRAP_FAULT</b>(n)   </td><td align=left> uninitialized user trap</tr><tr valign=top><td align=left>SIGFPE </td><td align=left> <b>FPE_FPA_ENABLE</b>      </td><td align=left> floating point disabled</tr><tr valign=top><td align=left>SIGFPE </td><td align=left> <b>FPE_FPA_ERROR</b>       </td><td align=left> floating point exception</tr><tr valign=top><td align=left>SIGFPE </td><td align=left> <b>FPE_INTDIV_TRAP</b>     </td><td align=left> zero divide</tr><tr valign=top><td align=left>SIGEMT </td><td align=left> <b>EMT_TAG</b>             </td><td align=left> tag overflow</tr><tr valign=top><td align=left></tr></tr></table></blockQuote><h4>Intel i960</h4><blockQuote><table><tr valign=top><th align=left>Signal  </th><th align=left> Code                           </th><th align=left> Exception</tr><tr><td colspan="3"><hr></tr><tr valign=top><td align=left>SIGBUS  </td><td align=left> <b>BUS_UNALIGNED</b>                  </td><td align=left> address error (bad alignment)</tr><tr valign=top><td align=left>SIGBUS  </td><td align=left> <b>BUS_BUSERR</b>                     </td><td align=left> bus error</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_INVALID_OPCODE</b>             </td><td align=left> invalid instruction</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_UNIMPLEMENTED</b>              </td><td align=left> instr fetched from on-chip RAM</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_INVALID_OPERAND</b>            </td><td align=left> invalid operand</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_CONSTRAINT_RANGE</b>           </td><td align=left> constraint range failure</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_PRIVILEGED</b>                 </td><td align=left> privilege violation</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_LENGTH</b>                     </td><td align=left> bad index to sys procedure table</tr><tr valign=top><td align=left>SIGILL  </td><td align=left> <b>ILL_TYPE_MISMATCH</b>              </td><td align=left> privilege violation</tr><tr valign=top><td align=left>SIGTRAP </td><td align=left> <b>TRAP_INSTRUCTION_TRACE</b>         </td><td align=left> instruction trace fault</tr><tr valign=top><td align=left>SIGTRAP </td><td align=left> <b>TRAP_BRANCH_TRACE</b>              </td><td align=left> branch trace fault</tr><tr valign=top><td align=left>SIGTRAP </td><td align=left> <b>TRAP_CALL_TRACE</b>                </td><td align=left> call trace fault</tr><tr valign=top><td align=left>SIGTRAP </td><td align=left> <b>TRAP_RETURN_TRACE</b>              </td><td align=left> return trace fault</tr><tr valign=top><td align=left>SIGTRAP </td><td align=left> <b>TRAP_PRERETURN_TRACE</b>           </td><td align=left> pre-return trace fault</tr><tr valign=top><td align=left>SIGTRAP </td><td align=left> <b>TRAP_SUPERVISOR_TRACE</b>          </td><td align=left> supervisor trace fault</tr><tr valign=top>

⌨️ 快捷键说明

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