Re: XForms: Problems with mutliple windows (fwd)

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 10 Feb 99 18:27:50 PST

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> I have a program that opens multiple forms, a main form, a gl drawing form
> and other sub forms. The program forks (really using the SGI sproc call
> with PR_SADDR) off a sub -process (a long "for" loop) which does some
> computation (polling of serial and audio ports) and udpates opened forms
> (buttons, lights, text, inputs and browsers) as it loops. ...

You cannot talk to the server from more than one process over the same
connection. This will confuse Xlib and give you the notorious "xlib
synch" error your report.

I realize that sproc() is different than fork() in the way address
spaces are maintained but I'm suspecting that Xlib still gets itself
out of synch as requests are sent to the server. I don't believe that
Xlib or XForms, for that matter, are thread safe or that things like
counters are guarded by mutexes or semaphores, so eventually both
processes will end up trying to increment a counter at the same time
and wham! you lose.

What flags are you using in the `inh' parameter? You may be able to
set PR_SADDR | PRSFDS and make it work but I'm doubtful.

OpenGL will also act strangely since only one process can own a
GLXContext at any particular instant so you will have to lock any
references to them with a mutex or semaphore.

If you need to update a form from a subprocess, you should use a
socket, IPC message queue, or some other mechanism to communicate
between the parent and child processes and allow only one process to
communicate with XForms.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/