[RFC]why xnlock_put and xnlock_clear_irqon release xnlock directly?

alex_luca at 163.com alex_luca at 163.com
Thu Jul 9 17:25:09 CEST 2020

From: Alex_luca at 163.com

I have some doubts on *struct nklock* operations. 

Both *xnlock_get* and *xnlock_get_irqsave* is allowed to be called
nested;they will check that if the nklock has been acquired. If so
they won't actually do the "get", but return a value of 2.

But the *xnlock_put*, which corresponding to *xnlock_get* never
checks and will actually release the lock. This is diffrent from

What puzzles me is the following:
    xnlock_get_irqsave(nklock, s)
    xnlock_put_irqrestore(nklock, s)

First, *xnlock_get_irqsave* get the nklock, and *xnlock_get* will skip;
Then *xnlock_put* is called, and it released the nklock; after a
while *xnlock_put_irqrestore* is called on the same cpu, it also seems
to release the nklock.

Will this above happen in xenomai?  But I have never seen this happen.
Or *xnlock_get* was guaranteed never been called nesting?

Thank you.

More information about the Xenomai mailing list