Skip to contentSkip to conversation

Have condition variables Priority Inheritance Protection (PIP)?

Xenomai-help Rodrigo Rosenfeld Rosas 2 participants 7 messages Apr 28, 2006 – May 4, 2006

lore
Share & tools
lore
#0 lore raw

Hi,
Having a look at cond.c in the native skin, I didn't understand why it is not passed the PIP flag to xnsynch_init(). I mean, why the code is not xnsynch_init(&cond->synch_base,XNSYNCH_PIP);

instead of

xnsynch_init(&cond->synch_base,XNSYNCH_PRIO);

?

Could someone please point me the reason?

Thanks in advance,

Rodrigo.

_______________________________________________________
Abra sua conta no Yahoo! Mail: 1GB de espaço, alertas de e-mail no celular e anti-spam realmente eficaz.
http://br.info.mail.yahoo.com/

#1 lore raw
Quoted 5 lines · Rodrigo Rosenfeld Rosas

Hi,
Having a look at cond.c in the native skin, I didn't understand why it is not passed the PIP flag to xnsynch_init(). I mean, why the code is not xnsynch_init(&cond->synch_base,XNSYNCH_PIP);

Quoted 8 lines

instead of

xnsynch_init(&cond->synch_base,XNSYNCH_PRIO);

?

Could someone please point me the reason?

Just as with semaphores: there is no ownership concept for condition variables. Thus, who should be boosted to your priority in case you decide to wait on such a resource?

Jan

#2 lore raw

Em Sexta 28 Abril 2006 17:42, Jan Kiszka escreveu:

Quoted 6 lines

...

Quoted 1 line

Could someone please point me the reason?

Just as with semaphores: there is no ownership concept for condition variables. Thus, who should be boosted to your priority in case you decide to wait on such a resource?

Sorry, you are right. Xenomai has no way of knowing which tasks could signal the condition variable. If I wanted to wait on some resource using priority inheritance I guess I would have to raise the priority of the task owning the resource manually when only one task can signal the condition variable (or semaphore). Do you know other better approaches? I mean if a task A of priority 50, shares a resource with task B and C, both priority 10 through semaphores. Suppose B and C are using the semaphore when A requests it. How could they be boosted to A's priority, so that A is protected with priority inheritance and then go back to their original priorities? Or should I use other IPC mechanism for sharing resource with PIP?

Thanks in advance,

Rodrigo.

_______________________________________________________
Abra sua conta no Yahoo! Mail: 1GB de espaço, alertas de e-mail no celular e anti-spam realmente eficaz.
http://br.info.mail.yahoo.com/

#3 lore raw
Quoted 8 lines · Rodrigo Rosenfeld Rosas

Em Sexta 28 Abril 2006 17:42, Jan Kiszka escreveu:

Quoted 5 lines

...

Quoted 1 line

Could someone please point me the reason?

Just as with semaphores: there is no ownership concept for condition variables. Thus, who should be boosted to your priority in case you decide to wait on such a resource?

Quoted 10 lines

Sorry, you are right. Xenomai has no way of knowing which tasks could signal the condition variable. If I wanted to wait on some resource using priority inheritance I guess I would have to raise the priority of the task owning the resource manually when only one task can signal the condition variable (or semaphore). Do you know other better approaches? I mean if a task A of priority 50, shares a resource with task B and C, both priority 10 through semaphores. Suppose B and C are using the semaphore when A requests it. How could they be boosted to A's priority, so that A is protected with priority inheritance and then go back to their original priorities? Or should I use other IPC mechanism for sharing resource with PIP?

Mutexes were invented for such resource access control :). They have a strict ownership concept, thus allowing to apply PIP as well.

Jan

#4 lore raw

Em Quarta 03 Maio 2006 04:57, Jan Kiszka escreveu:

Quoted 5 lines
Quoted 2 lines

...Or should I use other IPC mechanism for sharing resource with PIP?

Mutexes were invented for such resource access control :). They have a strict ownership concept, thus allowing to apply PIP as well.

Yes, however I can't figure out how could I use mutexes as counting semaphores, for instance. They have different meanings. However I could think in semaphores protected by PIP in singular cases, although I couldn't figure out how to do it in a systematic approach so that it could be used in a realtime framework such as Xenomai...

Rodrigo.

_______________________________________________________
Abra sua conta no Yahoo! Mail: 1GB de espaço, alertas de e-mail no celular e anti-spam realmente eficaz.
http://br.info.mail.yahoo.com/

#5 lore raw
Quoted 4 lines · Rodrigo Rosenfeld Rosas

Em Quarta 03 Maio 2006 04:57, Jan Kiszka escreveu:

Quoted 2 lines
Quoted 2 lines

...Or should I use other IPC mechanism for sharing resource with PIP?

Quoted 9 lines
Quoted 2 lines

Mutexes were invented for such resource access control :). They have a strict ownership concept, thus allowing to apply PIP as well.

Yes, however I can't figure out how could I use mutexes as counting semaphores, for instance. They have different meanings. However I could think in semaphores protected by PIP in singular cases, although I couldn't figure out how to do it in a systematic approach so that it could be used in a realtime framework such as Xenomai...

So you have to protect a multi-instance resource which can be used by a certain number of tasks in parallel? Is this a real scenario or just a hypothetical?

Let's consider it's real: this means that every task successfully requesting the resource becomes one of the owners. So you would have to maintain a list of owners, not just a single reference as with mutexes. Once someone requests the resource when there are no instances left, at least one of the owners should be boosted to the requesters priority.

All feasible, but probably so special with traps and pitfalls (think of initialising or handling multiple requests by the same tasks) that no one yet developed a generic mechanism for any OS I know of. But you are always free to do so based on existing elementary mechanisms. :)

Jan

#6 lore raw

Em Quinta 04 Maio 2006 03:54, Jan Kiszka escreveu:

Quoted 10 lines
Quoted 6 lines

...
Yes, however I can't figure out how could I use mutexes as counting semaphores, for instance. They have different meanings. However I could think in semaphores protected by PIP in singular cases, although I couldn't figure out how to do it in a systematic approach so that it could be used in a realtime framework such as Xenomai...

So you have to protect a multi-instance resource which can be used by a certain number of tasks in parallel? Is this a real scenario or just a hypothetical?

Just hypothetical for now. I guess I am preparing myself to the questions that could arrive about Xenomai when presenting my master thesis (if I will present it at all :) )

Quoted 3 lines

Let's consider it's real: this means that every task successfully requesting the resource becomes one of the owners. So you would have to maintain a list of owners, not just a single reference as with mutexes.

Another way would be make Xenomai maintain this list of owners that would be updated in rt_sem_p calls, doesn't it?

Quoted 2 lines

Once someone requests the resource when there are no instances left, at least one of the owners should be boosted to the requesters priority.

Right.

Quoted 2 lines

All feasible, but probably so special with traps and pitfalls (think of initialising or handling multiple requests by the same tasks)

I tried to, but couldn't figure out which would be those pitfalls.

Quoted 2 lines

that no one yet developed a generic mechanism for any OS I know of. But you are always free to do so based on existing elementary mechanisms. :)

Maybe after my deadline ;)

Thank you,

Rodrigo.

_______________________________________________________
Abra sua conta no Yahoo! Mail: 1GB de espaço, alertas de e-mail no celular e anti-spam realmente eficaz.
http://br.info.mail.yahoo.com/