nested task lock/unlock in rtems?

Joel Sherrill <> joel.sherrill at
Tue Jan 11 16:22:23 UTC 2005

Smith, Gene wrote:
> Can rtems keep track of nested calls to disable/enable preemption?
> E.g. within a task:
> lock
>     lock
>         lock
>         unlock
>     unlock
> unlock
> Where preemption is disabled on the first lock and not re-enabled until 
> the last unlock is called? And lock and unlock could be accomplished by 
> a call to rtems_task_mode. But is there anything in rtems to ensure a 
> balance?

Do you mean via premption via the rtems_task_mode service?

If so, then no.

If you mean via the critical section routines _Thread_Disable_dispatch
and friends, then the answer is yes -- a nest count is maintained.

> -gene

Joel Sherrill, Ph.D.             Director of Research & Development
joel at                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
    Support Available             (256) 722-9985

More information about the users mailing list