All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Michael Pustylnik <MichaelPustylnik@ruggedcom.com>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] Mutex enhancement for Auto relaxed threads
Date: Fri, 23 Nov 2012 12:15:43 +0100	[thread overview]
Message-ID: <50AF5ADF.4090502@siemens.com> (raw)
In-Reply-To: <990B36E792F1A4488D3E2B1C46FD62D69A13775FD4@corpmail2>

On 2012-11-22 17:55, Michael Pustylnik wrote:
> Although you can use mutexes in this order, why would you want to do that? Logically, unlocking mutex1 would mean finishing some operation started when mutex1 was locked. If as a part of the operation you locked mutex2 and haven't unlocked it yet, that would mean you haven't completed your operation yet, and unlocking mutex1 at this point would probably be a bug. Am I wrong?

I'm not aware that POSIX or some other APIs Xenomai implements forbid
such an ordering. And you never know if there is weird convoluted legacy
code out there that depends on exactly this.

However, I think you can avoid the limitation by attaching the property
"trap to kernel on mutex lock" to the thread instead of some mutex,
analogously to xeno_current_mode.

Jan

PS: Please no top postings!

> -----Original Message-----
> From: xenomai-bounces@xenomai.org [mailto:xenomai-bounces@xenomai.org] On Behalf Of Gilles Chanteperdrix
> Sent: Thursday, November 22, 2012 11:15 AM
> To: Makarand Pradhan
> Cc: xenomai@xenomai.org
> Subject: Re: [Xenomai] Mutex enhancement for Auto relaxed threads
> 
> On 11/22/2012 04:51 PM, Makarand Pradhan wrote:
>> Greetings,
>>
>> I have a proposal for enhancing the process of locking a real-time mutex in auto-relaxed Xenomai threads. It will  save a lot of CPU cycles in some scenarios, and I would like to get your expert opinion about it (I have coded the enhancement for native skin and changes are attached to this email).
>>
>> Xenomai mutex is designed in such a way that trapping to the kernel is not needed.This is a very efficient design which saves a great deal of CPU cycles.
>> However, there is an exception to this efficient behavior: if the Xenomai thread is an auto-relaxed thread (i.e. running with priority 0), locking a mutex always traps to the kernel because the current implementation handles auto-relaxing upon exiting the system call.
>>
>> Look at this scenario:
>>
>> A Xenomai thread
>> 1) locks a mutex (which is an OUTER mutex in this scenario)
>> 2) then loops multiple times through some operation that requires locking an unlocking some other mutex (INNER mutex)
>> 3) unlocks the OUTER mutex
> 
> I did not look in details at your code, but what if I do
> 
> lock mutex1
> lock mutex2
> unlock mutex1
> unlock mutex2
> 
> ?
> 

-- 
Siemens AG, Corporate Technology, CT RTC ITP SDP-DE
Corporate Competence Center Embedded Linux


  reply	other threads:[~2012-11-23 11:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-22 15:51 [Xenomai] Mutex enhancement for Auto relaxed threads Makarand Pradhan
2012-11-22 16:15 ` Gilles Chanteperdrix
2012-11-22 16:47   ` Makarand Pradhan
2012-11-22 19:24     ` Makarand Pradhan
2012-11-22 19:41       ` Makarand Pradhan
2012-11-22 16:55   ` Michael Pustylnik
2012-11-23 11:15     ` Jan Kiszka [this message]
2012-11-27 13:46       ` Gilles Chanteperdrix
2012-11-27 13:47         ` Jan Kiszka

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=50AF5ADF.4090502@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=MichaelPustylnik@ruggedcom.com \
    --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.