Signal handler & mutex, condition

Joel Sherrill joel.sherrill at oarcorp.com
Thu Jun 8 17:12:24 UTC 2006


Marek Prochazka wrote:

>>>In POSIX, I know that in general it is unsafe to use mutex or 
>>>condition
>>>within an asynchronous signal handler. Does RTEMS have a more 
>>>precisely
>>>defined policy on that? In other words, is anyone able to tell me
>>>      
>>>
>what
>  
>
>>>exactly is unsafe and whether some sort of a safe restricted use of
>>>      
>>>
>a
>  
>
>>>condition/mutex is possible?
>>>      
>>>
>
>  
>
>>The RTEMS manual explains which RTEMS primitives are safe
>>to call from (RTEMS) interrupt handlers. If you are using
>>the POSIX interface, you will need to figure out which
>>RTEMS primitives a given POSIX primitive is using, and then
>>check that all of them are safe.
>>    
>>
>
>The POSIX implementation uses the rtems_timer_create primitive. The
>RTEMS manual says that "Timer service routines may perform any
>operations or directives which normally would be performed by the
>application code which invoked the rtems_clock_tick directive".
>
>I also assume that the timer implementation uses asynchronous signal
>routines (ASRs). The RTEMS manual however says that "ASRs execute in the
>context of a task and may execute any directive."
>
>  
>
You would have assumed badly especially since you could have read the
source code.

Regular TSRs are invoked as part of processing the clock tick interrupt
handler and thus execute outside the context of any task/thread.

>My interpretation of this is that I do not have to worry about the use
>of mutexes and conditions in a timer service routine (and hence a POSIX
>timer callback). Any thoughts on this, please?
>
>  
>
You do have to worry about them -- you can't block at all during a TSR.

--joel

>Thanks,
>Marek
>
>  
>




More information about the users mailing list