Skip to contentSkip to conversation

Sharing of access to RT_MUTEX, RT_QUEUE, and RT_TASK

Xenomai-help Doug Brunner 2 participants 2 messages Jan 31, 2012

lore
Share & tools
lore
#0 lore raw

I'm working on an application where it would be convenient for several tasks within the same process to share access to single descriptors for mutexes, queues, and tasks, rather than each task having to separately bind to each one and keep its own RT_MUTEX/RT_QUEUE/RT_TASK.

The documentation doesn't seem to speak to this issue, and I haven't been able to find a definitive answer through searches. Can anyone clarify whether or not this will lead to problems, e.g. task A is in the midst of locking a mutex when task B starts trying to obtain a lock itself, and bad results occur?

Thanks,
Doug Brunner

#1 lore raw
Quoted 3 lines · Doug Brunner

I'm working on an application where it would be convenient for several tasks within the same process to share access to single descriptors for mutexes, queues, and tasks, rather than each task having to separately bind to each one and keep its own RT_MUTEX/RT_QUEUE/RT_TASK.

The documentation doesn't seem to speak to this issue, and I haven't been able to find a definitive answer through searches. Can anyone clarify whether or not this will lead to problems, e.g. task A is in the midst of locking a mutex when task B starts trying to obtain a lock itself, and bad results occur?

Descriptors in user-space only contain handles to kernel objects, they carry no object properties; on the contrary, their kernel space counterparts do carry object information.

So, from user-space, you can share descriptors between threads which belong to the same process freely. The same way, cloning a descriptor in user-space using bitwise-copy does produce a valid descriptor to the original object.

Binding is meant to be used in two cases:
- when the original object descriptor is not in the same address space (i.e. created by a different process, or created in kernel space)
- when the caller wants to wait for some object to be created, in which case the binding operation provides the required synchronization mechanism as a bonus.

In the case you describe, there is no problem in considering object descriptors as globally shared variables.

Quoted 10 lines

Thanks,
Doug Brunner

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 1 line
Philippe.