Quoting Linus Torvalds ([EMAIL PROTECTED]):
> 
> On Fri, 30 May 2003, Denis Oliver Kropp wrote:
> > 
> > In the kernel part of Fusion (our IPC API) I'm currently calling yield()
> > after unlocking a "long-time" lock. Maybe you have some hints before I'm
> > working on that issue.
> 
> You really shouldn't unconditionally yield. That just tells the kernel 
> that you don't have anything to do, and since it isn't "directed" any way 
> the kernel can't really do anything smart about it, and has to assume that 
> you're less important than basically _all_ other programs (modulo nice 
> levels).
> 
> Which looks like it works for many trivial cases, and gives _wonderful_ 
> interactivity, but you'll see just how much it sucks if you ever have a 
> compile going on in the background, and you continually yield to it and 
> tell the system that the compile is more important than you are. See the 
> problem?

Yes, I think for now I can add a check to call yield() only if another
task is waiting for the lock.

> You _really_ want to use futex'es for any user-space locking. It's
> back-ported to 2.4.x, and it gets these cases _right_. There are fair
> user-space locks based on futexes as part of modern glibc sources, and
> they are _fast_, since all non-contention (common case) is done entirely
> in user space, and they do the right thing (*) when there is contention.

One special requirement to nearly all Fusion primitives is much like the
SEM_UNDO flag for SysV semaphores. Are futexes automatically unlocked if
the process that locked it gets killed by SIGKILL? Fusion also implements
reference counters that way. The problem with SysV semaphores was that the
undo counter is stored thread wise (Fusion stores it per file handle as
the API is a bunch of ioctls and the "release" file op does the cleanup).

> > BTW, you might want to look at Fusion when you have time (see our web cvs).
> 
> Docs/design where?

I'm sorry, there's no documentation or design paper yet.
But I will start writing one. A bit documentation can be found
in the headers of the user level part of Fusion in DirectFB/src/core/fusion.

> (*) Right thing: sleep and _directed_ wake-ups, no random yields.

I will have a look at the futex implementation, thanks.

-- 
Best regards,
  Denis Oliver Kropp

.------------------------------------------.
| DirectFB - Hardware accelerated graphics |
| http://www.directfb.org/                 |
"------------------------------------------"

                            Convergence GmbH


-------------------------------------------------------
This SF.net email is sponsored by: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to