[comp.sys.sgi] Interrupting long draw cycles

Dan Karron@UCBVAX.BERKELEY.EDU (03/12/91)

I am curious about using this technique:

I want to change the viewing parameters of a drawing loop. I want
to interrupt the drawing program with a signal, say SIGUSR1. The signal
handler will then do a longjmp back to the main drawing loop with
new eye position and viewing values and start drawing.

This will entail the gl calls being interrupted and aborted at any step.

My experiments with this code have resulted in occational aborts of
the graphics subsystem and the system returning to pandora.

Is there a gracefull way to interrupt the gl subsystem to regain
control ? Can I stop a long draw cycle and start another without
dammage to the gl pipeline ?

Cheers!


Dan.
+-----------------------------------------------------------------------------+
| karron@nyu.edu (E-mail alias that will always find me)                      |
| Fax: 212 263 7190           *           Dan Karron, Research Associate      |
| . . . . . . . . . . . . . . *           New York University Medical Center  |
| 560 First Avenue           \*\    Pager <1> (212) 397 9330                  |
| New York, New York 10016    \**\        <2> 10896   <3> <your-number-here>  |
| (212) 263 5210               \***\_________________________________________ |
| Main machine: karron.med.nyu.edu (128.122.135.3) IRIS 85GT                  |
+-----------------------------------------------------------------------------+

sweetmr@SCT60A.SUNYCT.EDU (michael sweet) (03/12/91)

(other stuff deleted...)

> This will entail the gl calls being interrupted and aborted at any step..

> My experiments with this code have.....

I assume that you want to jump out of this when a user says 'no, try this
view'?  Well, one way would be to use the qgetfd() function to get a
file descriptor for the event queue, and then start a separate process that
would monitor the queue.  When something becomes available on the queue,
the process could send a SIGIO (or whatever) signal to its parent telling
it to stop drawing and get the new viewing parameters.  You'd probably want
to disable 'noisy' devices (i.e. MOUSEX, MOUSEY).  The signal catching routine
in the primary (drawing) process could set a flag which the drawing function
could check periodically.

I *think* 3.3 and later also allow multi-process access to the same window,
so you might not have to get the file descriptor....




 -Mike Sweet

------------------------------------------------------------------------------
"The only        TASC                      (315) 724-1100 (voice)
 truth is that   555 French Road           (315) 724-2031 (fax)
 there are no    New Hartford, NY  13413   Internet: sweetmr@sct60a.sunyct.edu
 truths, only beliefs."                    Delphi:   DODGECOLT
------------------------------------------------------------------------------

reuel@khaki.asd.sgi.com (Reuel Nash) (03/13/91)

In article <9103112256.AA08202@karron.med.nyu.edu>, Dan Karron@UCBVAX.BERKELEY.EDU writes:
> I want
> to interrupt the drawing program with a signal, say SIGUSR1. The signal
> handler will then do a longjmp back to the main drawing loop with
> new eye position and viewing values and start drawing.
> 
> This will entail the gl calls being interrupted and aborted at any step.
> 
	Don't do it this way. Commands and data written by the gl must
	be complete or you can take the graphics system down.

> Is there a gracefull way to interrupt the gl subsystem to regain
> control ? Can I stop a long draw cycle and start another without
> dammage to the gl pipeline ?
> 
	The appropriate thing to do is to have your signal handler 
	set a flag that is checked syncronously by your main drawing
	loop. This can (and should) be at a higher level than every line
	or polygon. If data is organized as objects, check after drawing
	each object. If data is not organized as objects, check after 
	drawing every N objects, where N is set by your desired response
	time and drawing rate. The flag should be declared 'volatile'
	or the optimizer will think it can't change inside the loop
	and may optimize it away.
> 
> Dan.



Reuel Nash				Email:		reuel@sgi.sgi.com  
"Question Skepticism"			Voicemail:	(415)962-3254  
Mail stop:SR-254 Work Phone:(713)266-1333 Home Phone:(713)589-6258
USMail:	 Silicon Graphics, 5858 Westheimer Suite 100, Houston, TX  77057