Dispatching and scheduling--basic questions
peter.harris at hummingbird.com
Mon Sep 15 16:34:39 PDT 2008
William Tracy wrote:
> In response to Adam and Tiago's emails, I'm looking at the dispatching
> and scheduling code, respectively. The most relevant file *seems* to
> be xserver/dix/dispatch.c, though grep pulls up some stuff under
> xserver/Xext and xserver/Xi. Any other relevant code I'm missing?
xserver/dix/dispatch.c is the main file, yes. xserver/os/WaitFor.c also
springs to mind.
> I have to ask, though: Why does Xorg even have its own scheduler?
> Unless I am completely misunderstanding its purpose, it seems like
> this should be pushed off to the OS via pthread. Is this a way of
> sidestepping concurrency issues by forcing everything to run in one
> thread at the kernel level?
For starters, X11 (released 1987, if you ignore X10 and predecessors)
has been around rather longer than pthreads (POSIX 1003.1c-1995).
More to the point, every time I think about trying to thread the server,
I stall with one of two designs. Either one big lock that all the
threads are blocking on (and then you have to write a lock scheduler
anyway), or a bazillion little locks, and common ops like "Grab Server"
or "Configure Window" having to take them all (which sounds slow). Even
with many small locks, I suspect you'd still have most (non-idle)
threads blocking on the graphics driver lock much of the time.
I haven't spent all that much time thinking about a threaded server,
however. Maybe you can come up with a better design.
> The more I look at X11, the more it looks like a second kernel in userspace. :-)
Well, yes. Something has to arbitrate access to each limited resource.
Some OSes do in fact put the graphics layer in the kernel.
Hummingbird Connectivity - A Division of Open Text
Peter Harris http://connectivity.hummingbird.com
Research and Development Phone: +1 905 762 6001
peter.harris at hummingbird.com Toll Free: 1 877 359 4866
More information about the xorg