Jan 6, 2008

About signal handling function

After running some test on FreeBSD 5.4-STABLE (Duo core machine) I've found that:

1. Signal handler function and main program won't execute concurrently.
(Not time-shared, Non-interleaved execution, Won't run on different core)

2. If multiple signal arrives:
a. Signal handler functions won't execute concurrently.
b. Later come serves first.
c. The signal number does not mean the priority of signal.
(ex: When USR1 is processing, USR2 arrives, USR2 will be served immediately. Vice versa.)
d. If the same signal is processing, and comes again, it'll be stacked. And also, later come serves first.
ex: When
USR1(a) processed in the half.
USR2(a) is processing.
USR1(b) comes again.
USR2(b) comes again.
The remaining execution order will be:
USR2(a), USR2(b), USR1(b), USR1(a), Main Program


zmx said...

If you want priority, you need POSIX real time signal


When multiple unblocked signals, all in the range SIGRTMIN to SIGRTMAX, are pending, the behavior shall be as if the implementation delivers the pending unblocked signal with the lowest signal number within that range. No other ordering of signal delivery is specified.

pigfoot said...

How could you get the first conclusion? Based on some testings or something else?

cooldavid said...

to pigfoot:
Based on testing.
I've tried to implement a very-long-time signal handler, and see if the main process is running (time shared) with it.