From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Philippe Gerum <rpm@xenomai.org>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] Issue with Auto relax and nested mutexes
Date: Thu, 19 Jan 2012 13:29:54 +0100 [thread overview]
Message-ID: <4F180CC2.8020700@domain.hid> (raw)
In-Reply-To: <4F17FD9E.6040007@domain.hid>
On 01/19/2012 12:25 PM, Philippe Gerum wrote:
> On 01/18/2012 11:41 PM, Makarand Pradhan wrote:
>> Hi,
>>
>> Another problem was encountered with rescnt related to nested mutexes.
>>
>> This time the rescnt is not incrementing because the XNOTHER bit is not
>> set, causing a SIGDEBUG or SIGXCPU to be delivered to the thread causing
>> my application to crash.
>>
>> The scenario is as follows:
>>
>> 1. Thread started with priority 0. (Relaxed)
>> 2. This thread uses mutexes which causes Priority Inversions.
>> 3. At some point, a rt_task_set_priority is done to change the priority.
>> (RT 85).
>> 4. Some time later the priority is set back to 0.
>
> If I understand it properly, your runtime scenario is badly broken I'm
> afraid. By contrast to priority ceiling, priority inheritance is about
> leaving the responsibility to the _kernel_ to pick the best dynamic
> priority for your thread to solve a priority inversion.
>
> Therefore, by changing your dynamic priority while holding a mutex, your
> application is preventing the kernel to do the job you previously
> assigned to it. Worst, you could be causing unexpected latencies to
> other threads your application has no clue about, or just can't tell
> whether they compete with your thread for accessing the resource at that
> specific time.
>
> After all, this is your application that defined the contented mutex,
> and as such the fact that priority inheritance might be involved at some
> point. If you don't trust the kernel and want to deal with priorities
> manually during resource contention, then maybe you should use a
> different mutual exclusion mechanism not implementing priority
> inheritance, e.g. a plain binary semaphore.
Even if you implement manual priority ceiling, you should change
priority before acquiring the mutex, not after, otherwise there is a
race condition.
--
Gilles.
next prev parent reply other threads:[~2012-01-19 12:29 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-09 20:50 [Xenomai-help] Issue with Auto relax and nested mutexes Makarand Pradhan
2012-01-10 15:11 ` Philippe Gerum
2012-01-10 15:26 ` Makarand Pradhan
2012-01-10 15:38 ` Philippe Gerum
2012-01-10 15:40 ` Makarand Pradhan
2012-01-10 15:40 ` Philippe Gerum
2012-01-10 15:42 ` Philippe Gerum
2012-01-10 15:51 ` Makarand Pradhan
2012-01-10 17:51 ` Philippe Gerum
2012-01-10 18:08 ` Philippe Gerum
2012-01-10 18:39 ` Makarand Pradhan
2012-01-10 19:10 ` Makarand Pradhan
2012-01-10 20:30 ` Philippe Gerum
2012-01-18 22:41 ` Makarand Pradhan
2012-01-19 10:17 ` Gilles Chanteperdrix
2012-01-19 11:25 ` Philippe Gerum
2012-01-19 12:29 ` Gilles Chanteperdrix [this message]
2012-01-19 15:35 ` Makarand Pradhan
2012-01-19 15:22 ` Makarand Pradhan
2012-01-19 15:49 ` Philippe Gerum
2012-01-19 16:22 ` Makarand Pradhan
2012-01-19 16:39 ` Makarand Pradhan
2012-01-23 15:01 ` Makarand Pradhan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F180CC2.8020700@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=rpm@xenomai.org \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.