From: Matthieu CASTET <matthieu.castet@parrot.com>
To: Esben Nielsen <nielsen.esben@googlemail.com>
Cc: "Sébastien Dugué" <sebastien.dugue@bull.net>,
linux-rt-users@vger.kernel.org
Subject: Re: IBM test question
Date: Tue, 12 Feb 2008 11:57:48 +0100 [thread overview]
Message-ID: <47B17BAC.2000105@parrot.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0802121108010.11973@frodo.shire>
Hi,
Esben Nielsen wrote:
>
>>>> for userland atomic operations (aside from swapping).
>>> I can, if I use a kernel helper :) [1]
>>
>> Yep, but much slower.
>>
>
> I worked with an ARMv4 at my former job and wanted to run Linux on it. I
> thus gave this problem a thought. I got the following idea:
> Make a user space preemt-disable counter just like the in-kernel one.
> This can be done by registering a address in userspace per thread
> pointing where to find the counter. When the kernel wants to schedule it
> checks if the counter is non-zero. If it is (the very rare case), it
> doesn't reschedule but sets up a timer of some configurable time (say 1
> ms or
> whatever you need). If the counter is not back to 0 after the timer has
> expired we schedule anyway and signals the thread to let it know that an
> atomic operation have failed. Notice, that this can only happen due to an
> error in the program: You must always be able finish your atomic
> operations in 1 ms.
>
> (There are a lot of details to this, ofcourse. Forinstance. in the case
> the kernel wanted to schedule and sets up he timer, the user space
> program needs to know it so it can disable the timer reschedule as soon
> as the counter reaches 0. And there is the problem of not swapping out
> the page where the counter is stored....)
>
The kernel helper is not slow for armv5. There no userspace->kernel
switch with some magic. That's just 15 instructions instead of one.
The kernel helper is at a special address. When a context switch occurs,
the kernel check if it wasn't in the helper and finish the atomic
operation or set a flag.
Matthieu
prev parent reply other threads:[~2008-02-12 10:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-07 13:49 IBM test question Matthieu CASTET
2008-02-07 15:34 ` Sébastien Dugué
2008-02-07 16:27 ` Matthieu CASTET
2008-02-08 9:06 ` Sébastien Dugué
2008-02-12 10:19 ` Esben Nielsen
2008-02-12 10:57 ` Matthieu CASTET [this message]
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=47B17BAC.2000105@parrot.com \
--to=matthieu.castet@parrot.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=nielsen.esben@googlemail.com \
--cc=sebastien.dugue@bull.net \
/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.