Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!vsi1!daver!athsys!fred
From: fred@athsys.uucp (Fred Cox)
Newsgroups: comp.windows.x
Subject: Unix Signals and Xlib
Keywords: Signal, Unix, X11
Message-ID: <148@poseidon.UUCP>
Date: 22 Sep 88 01:18:28 GMT
Reply-To: fred%athsys.uucp@sun.com (Fred Cox)
Organization: Athena Systems, Inc., Sunnyvale, CA
Lines: 32

We have an application that includes a real time simulator that needs
timer events, and also does things that can take a while during which
we can't conveniently process X events.

There are two things that we are doing to solve these problems that mix
signals and X.  One is to process X events while something is running
that takes a long time, such as calling "system()".  The other is
regular timer events to have the simulator run in real time.

Our faulty solution to the first problem sets a timer to run, and
checks X for the next Exposure event, and processes it.

The second problem involves setting the timer, and sending a
ClientMessage back to our own process, so that we can use XNextEvent.

Apparently our solutions cause big problems, though.  We get lots
of errors like: "sequence lost!", and "XError( 1): 
XID(000000), Serial(1964/2101) Minor(  0) Major(0)".

All the signals that we use are SIGALRM, so that we can have things
that happen in something approaching real time.  We have cases in which
an XCheckIfEvent is called at signal level, and also in which drawing
commands and ClientMessages are sent from signal level.

There seems to be a pair of macros called LockDisplay and UnlockDisplay,
but these are not implemented in the Sun 3 version.  Would these help
if they were implemented?  Has anyone implemented them?

Can anyone suggest another scheme that will get around these problems?

------------------------
Fred Cox, reachable at: sun!athsys!fred