nested task lock/unlock in rtems?
Smith, Gene
gene.smith at siemens.com
Tue Jan 11 20:11:44 UTC 2005
Joel Sherrill <joel at OARcorp.com> wrote, On 1/11/2005 2:03 PM:
> Smith, Gene wrote:
>
>>
>>Joel Sherrill <joel at OARcorp.com> wrote, On 1/11/2005 11:22 AM:
>>
>>
>>>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?
>>
>>
>>
>>Yes, as documented in the "RTEMS C User's Guide".
>>
>>
>>>If so, then no.
>>
>>
>>I can store the nest count in the task notepad value and accomplish what
>>I want using documented rtems_...() calls. But probably suboptimal.
>>
>>
>>>If you mean via the critical section routines _Thread_Disable_dispatch
>>>and friends, then the answer is yes -- a nest count is maintained.
>>
>>
>>This seems like a more direct way to accomplish what I want. Is it ok to
>>call these from a user task? I don't see it mentioned in the User's
>>Guide. It seem to be for internal rtems use. I assume the
>>"disable/enable dispatch" means stop/start preemption. I am trying to
>>port this functionality:
>>http://www.roe.ac.uk/atc/projects/vista/software/VxWorks/docs/vxworks/ref/taskLib.html#taskLock
>
>
> The internal routines are VERY dangerous to let a user application
> access. They disable SCHEDULING and if a task blocks while scheduling
> is disabled, the system is toast.
In my code, the taskLock/TaskUnlock pair just enclose a short critical
section which I don't think contains code that can block.
>
> Could implement the VxWorks functionality with a per task variable
> for the nest count and the current rtems_task_mode?
Yes, that is what I did, more or less. I just let RTEMS_NOTEPAD_0 be
"per task variable" for nest count. That way I just make
taskLock/taskUnlock substitutes (calling rtems_task_mode and
rtems_task_get/set_note) and add no new variables to the tasks.
Thanks for the info.
Gene
More information about the users
mailing list