9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@swtch.com>
To: 9fans <9fans@cse.psu.edu>
Subject: [9fans] [plan9port] graphics
Date: Wed, 28 Jun 2006 10:46:29 -0700	[thread overview]
Message-ID: <ee9e417a0606281046u10a8a596t5875dbcf3e8e8546@mail.gmail.com> (raw)

[Short version: new graphics code.  If you've seen problems
before, try the new code.  If you haven't seem problems,
keep an eye out for them.  Thanks.]

Over the weekend I restructured the way graphics programs
run under Plan 9 from User Space.  I'd been seeing frequent
mysterious hangs and X I/O errors in multithreaded graphics
programs running on Linux SMP machines using pre-NPTL
threading.

In Plan 9, a typical graphics program might have a proc
reading the keyboard, a proc reading the mouse, and another
proc executing draw operations with writes to files in
/dev/draw/.

I tried to preserve this model in Plan 9 from User Space,
using pthreads or explicitly-created shared-memory threads
on systems where pthreads wasn't good enough (e.g., Linux
pre-NPTL).  I allocated multiple connections (Displays) to
the underlying X server and gave one to each proc, though
there were one or two places where I had to cheat, letting
one proc send an asynchronous message to a Display that
another proc was reading.  I still don't know whether these
cut corners are what caused the trouble or whether there are
deeper problems with truly multithreaded X clients.

Whatever the reason, some combinations of X library,
X server, C library, threading library, and Linux kernel can't
seem to handle the way the ported Plan 9 programs were using
the interface.  My 9term windows would suddenly stop
accepting keyboard input, or stop accepting mouse input and
redraw requests.  Acme would do the same, though less
frequently.

Over the weekend I shuffled things around.  Instead of
linking X code into every program, there is now a single
program, called devdraw, that contains X interface code.
Graphical programs now fork and exec a devdraw and then
speak a simple protocol to its standard input and standard
output to read from the keyboard and mouse and draw on the
screen.  Devdraw is not a threaded program.  It runs on the
standard system stack and uses select(2) to manage its two
inputs.  It uses only a single connection to the X server.
My hope is that doing things the Official Unix Way inside
devdraw will eliminate the problems people have reported.

The main visible side effect of this change, other than
hopefully increased stability, is that if you want to run a
graphics program you'll need to have a devdraw binary
in your path.  If you copy samterm somewhere, you'll need
to copy devdraw too.

There are a few other cleanups and bug fixes.  See the
CHANGES file for more.

Please let me know of any problems.

Thanks.
Russ


             reply	other threads:[~2006-06-28 17:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-28 17:46 Russ Cox [this message]
2006-06-28 21:13 ` Jack Johnson
2006-06-28 21:42   ` Russ Cox
2006-06-29  2:04 ` Roman Shaposhnick
2006-06-29  3:59   ` David Leimbach
2006-06-29  4:27 ` quanstro
2006-06-29 15:36   ` Russ Cox
2006-06-29 18:59     ` Roman Shaposhnick
2006-07-12 15:36       ` andrey mirtchovski

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=ee9e417a0606281046u10a8a596t5875dbcf3e8e8546@mail.gmail.com \
    --to=rsc@swtch.com \
    --cc=9fans@cse.psu.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).