Thread (6 messages) 6 messages, 3 authors, 2008-02-12

Re: IBM test question

From: Matthieu CASTET <hidden>
Date: 2008-02-12 10:58:49

Hi,

Esben Nielsen wrote:
quoted
quoted
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help