Re: Signals and threads



Hello,

shibu-kundara wrote:

Hi.
Thanks for the response let me clear the question,

I have two thread registered two different signal handler
SigHndlrFuncA,SigHndlrFuncB
Both is registerd with SIGUSR1.
When i send SIGUSR1 signal to threadA why SigHndlrFuncB is getting
called instead of SigHndlrFuncA???

Because there is only one handler for all threads together possible. The
last time setting the handler will supersede the other times. Using
signals with threads is supposed to be done with directing the signals
to one specific thread per signal, via the masks. A signal is
implemented to be sent to a process, the actual thread receiving it is
a priori undefined. There is only one handler for all threads.

If you want to change this, you have to change the parts of the kernel
and the system libraries working together on this. There are signals
that don't make any sense to be reacted to by a single thread, so there
will be a lot of problems with the changes.

There are potentially better ways to communicate between threads than
signals, requiring fewer system calls, i.e. less overhead. So there has
never been a real need to extend signals to be used with threads more
easily.

Regards,

Bernd Strieder

.



Relevant Pages

  • Re: Using SetConsoleCtrlHandler
    ... "bare minimum" principal should work even in multithreaded POSIX apps, ... you rely on recursive lock acqusition in your "signal handler" - hard to ... POSIX signals to POSIX processes". ... "Kernel mode APCs interrupt a thread and execute a procedure without ...
    (microsoft.public.win32.programmer.kernel)
  • Re: SetConsoleCtrlHandler
    ... This modified handler does not call ... signals. ... This allows the service to continue running after the user logs ... If the service installs its own console control handler, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: pitfalls of signals
    ... If you have a signal handler that was invoked as a result of your program ... in that case you've invoked undefined behavior ... without invoking undefined behavior ... -Temporarily block a set of signals that includes the one the handler ...
    (comp.lang.c)
  • Re: Mars Rover Controlled By Java
    ... When handling signals Ada provides a higher level abstraction that ... -- Defines the interface for a signal handler ... task Responder is ... interrupt is handled only once. ...
    (comp.programming)
  • Re: Using SetConsoleCtrlHandler
    ... Assuming the signal handler does the minimum (ie. set a global, ... Only a single-threaded POSIX ... POSIX signals to POSIX processes". ... "Kernel mode APCs interrupt a thread and execute a procedure without the ...
    (microsoft.public.win32.programmer.kernel)