Signal是一种处理异常或异步改变执行流程的机制,类似于软中断。与POSIX兼容,VxWorks也定义了多种Signal(0为NULL Signal)
#define SIGHUP 1 /* hangup */ #define SIGINT 2 /* interrupt */ #define SIGQUIT 3 /* quit */ #define SIGILL 4 /* illegal instruction (not reset when caught) */ #define SIGTRAP 5 /* trace trap (not reset when caught) */ #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ #define SIGEMT 7 /* EMT instruction */ #define SIGFPE 8 /* floating point exception */ #define SIGKILL 9 /* kill */ #define SIGBUS 10 /* bus error */ #define SIGSEGV 11 /* segmentation violation */ #define SIGFMT 12 /* STACK FORMAT ERROR (not posix) */ #define SIGPIPE 13 /* write on a pipe with no one to read it */ #define SIGALRM 14 /* alarm clock */ #define SIGTERM 15 /* software termination signal from kill */ #define SIGCNCL 16 /* pthreads cancellation signal */ #define SIGSTOP 17 /* sendable stop signal not from tty */ #define SIGTSTP 18 /* stop signal from tty */ #define SIGCONT 19 /* continue a stopped process */ #define SIGCHLD 20 /* to parent on child stop or exit */ #define SIGTTIN 21 /* to readers pgrp upon background tty read */ #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ #define SIGRES1 23 /* reserved signal number (Not POSIX) */ #define SIGRES2 24 /* reserved signal number (Not POSIX) */ #define SIGRES3 25 /* reserved signal number (Not POSIX) */ #define SIGRES4 26 /* reserved signal number (Not POSIX) */ #define SIGRES5 27 /* reserved signal number (Not POSIX) */ #define SIGRES6 28 /* reserved signal number (Not POSIX) */ #define SIGRES7 29 /* reserved signal number (Not POSIX) */ #define SIGUSR1 30 /* user defined signal 1 */ #define SIGUSR2 31 /* user defined signal 2 */ #define SIGPOLL 32 /* pollable event */ #define SIGPROF 33 /* profiling timer expired */ #define SIGSYS 34 /* bad system call */ #define SIGURG 35 /* high bandwidth data is available at socket */ #define SIGVTALRM 36 /* virtual timer expired */ #define SIGXCPU 37 /* CPU time limit exceeded */ #define SIGXFSZ 38 /* file size time limit exceeded */ #define SIGEVTS 39 /* signal event thread send */ #define SIGEVTD 40 /* signal event thread delete */ #define SIGRTMIN 48 /* Realtime signal min */ #define SIGRTMAX 63 /* Realtime signal max */ #define _NSIGS 63
任务或ISR可以发送Signal到任务本身或其它任务;而对方可以根据Signal Mask选择接收还是忽略该Signal。如果要接收的话,需要注册Signal的处理函数
发送Signal时,使用的是发送者的上下文。而处理函数在处理接收到的Signal时,使用的是接收者的上下文。即使接收者阻塞或者挂起了,这个处理还是会执行的。
Signal的处理函数中可以调用的系统函数有这些
库 | 函数 |
bLib | All routines |
errnoLib | errnoGet(), errnoSet() |
eventLib | eventSend() |
fppArchLib | fppSave(), fppRestore() |
intLib | intContext(), intCount(), intVecSet(), intVecGet() |
intArchLib | intLock(), intUnlock() |
logLib | logMsg() |
lstLib | All routines except lstFree() |
mathALib | All routines, if fppSave()/fppRestore() are used |
msgQLib | msgQSend() |
rngLib | All routines except rngCreate() and rngDelete() |
semLib | semGive() except mutual-exclusion semaphores, semFlush() |
sigLib | kill() |
taskLib | taskSuspend(), taskResume(), taskPrioritySet(), taskPriorityGet(), taskIdVerify(), taskIdDefault(), taskIsReady(), taskIsSuspended(), taskIsPended(), taskIsDelayed(), taskTcb() |
tickLib | tickAnnounce(), tickSet(), tickGet() |
tyLib | tyIRd(), tyITx() |
vxLib | vxTas(), vxMemProbe() |
wdLib | wdStart(), wdCancel() |
spinLockLib | spinLockIsrTake() and spinLockIsrGive() |
vxAtomicLib | All routines. |
vxCpuLib | vxCpuIndexGet(), vxCpuIdGet(), vxCpuPhysIndexGet(), vxCpuIdToPhysIndex(), vxCpuPhysIndexToId(), vxCpuReservedGet(), CPU_LOGICAL_TO_PHYS(), and CPU_PHYS_TO_LOGICAL() |
fioLib | vsprintf() and vsnprintf() |
fioBaseLib | sprintf() and snprintf() |
ansiString | All routines. |