Subject: Re: "fast" syscalls?
To: Chapman Flack <>
From: Garrett D'Amore <>
List: tech-kern
Date: 03/17/2006 12:23:10
Chapman Flack wrote:
> Garrett D'Amore wrote:
>>> You may want to look at some of the audio drivers which allow you to
>>> mmap a buffer into userland.  From memory they handle the
>>> userland/kernel interaction by updating the head/tail pointers in a
>>> circular queue, userland updates one pointer and the kernel updates
>>> the other... when they pointers are equal the queue is empty.
> And if you adapt the classic 1 reader 1 writer circular queue convention
> where the queue is 'full' when w+1 == r (mod size), that is, when
> exactly one slot is unused, then you're in business as long as the
> pointer updates in your architecture are indivisible (which might
> require carefully making sure the pointers do not straddle page
> boundaries but otherwise ought to be a safe assumption - at least that
> seemed to be the consensus when I asked). The only time you'll ever need
> to use a u/k interaction to synchronize is when the reader or writer
> actually starves or blocks, and if you can adjust buffer sizes and
> processing rates so that happens seldom, you could keep the cost of that
> interaction down by not needing to do it often.

Because this isn't a constant stream of data, its updates when X wants
them, and because I don't know anything about underlying hardware
performance (which could be quite different), it might be hard to do
this.  If the hardware is very fast, then it could easily degenerate
into one syscall per update.

I'll have to play with it and see what happens.

    - -Garrett

Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
Phone: 951 325-2134  Fax: 951 325-2191