Subject: Re: wscons "usl_detachtimeout" (multiple X servers)
To: Robert Elz <kre@munnari.OZ.AU>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-kern
Date: 02/03/2000 21:52:13
kre@munnari.OZ.AU said:
> When xdm starts this way though, the kernel (wscons) prints
> "usl_detachtimeout" messages periodically, and switches to ttyE0 of
> its own volition.   It is possible to switch back, but a "xrefresh" is
> needed to get the X display back (the X server acts as if it had no
> idea that its display was yanked out from under it - though it does
> return to graphics mode). 

As far as I see, this is due to brokeness in the USL virtual
console switching protocol, or at least in the way Xfree86
deals with it.
The X server does the following (from memory, sorry if I miss something):
1. open the first vt
2. find out the first free virtual screen
3. close it and open the vt device of the free one or what got passed
   on the command line
4. tell it to switch to it
5. wait for the switch to be done
6. initiate process synchronisation, ie reserve it for use by the X server
7. begin graphics initialisation

Now there is a race condition and a timing problem: if another process
switches the screen away between (5) and (7), the X server can do hardware
actions while not actually posessing the screen, and if another process
got in posession of the screen and does longish things, (5) can
time out.
Imho the X server must do (6) first - it can posess a screen while the
screen is not yet active -, and should do some error handling in
case of switch timeouts, eg retry.
As far as I can see, this would break with pcvt, which contains some
specific hacks to avoid the race condition which I refused to adopt
because they are broken in other ways.
The right thing would be to stop using a pcvt compatibility mode in
Xfree86 and do it better from the beginning.
The problem didn't bother me enough to spend time on it, and now we'll
get Xfree86 v4 soon, so it is kind of pointless to hack on the
old codebase.
A workaround could be to delay the startup of one of the X servers
for some seconds - use a script which does "sleep 5; exec X $*" instead
of one of the entries in Xservers. (just a guess, didn't try)

Would be nice to get some help with the console-X stuff...

best regards
Matthias


best regards
Matthias