[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

3328.0. "Xlib, is it signal safe" by EVETPU::REINIG (This too shall change) Mon Sep 10 1990 22:48

    I know that Xlib is AST reentrant.  Is it also Signal safe on ULTRIX?
    
                                August G. Reinig
T.RTitleUserPersonal
Name
DateLines
3328.1Xlib is not 100% signal safeOXNARD::KLEEKen LeeTue Sep 11 1990 14:4216
    Xlib is not 100% signal safe.  UNIX signals are heavyweight and
    protecting against them in Xlib is too expensive.  You can use signals
    safely if you do not make Xlib calls in your signal handlers.  If you
    must make Xlib calls in the signal handlers, you must be sure that all
    the Xlib queues are empty before you make the call.  Alternatively, you
    can block signals when the queues are not empty.
    
    One alternative is to use two Xlib connections, one for normal use and
    the other for your signal handlers (assuming that signals will not
    interupt each other).
    
    Another possibility is to use the timer and file descriptor handlers in
    the X Toolkit.  These mess with select() instead of signals.
    
    Ken
    
3328.2So how do we handle events in a long operationEVETPU::REINIGThis too shall changeTue Sep 11 1990 15:2712
    If Xlib isn't signal safe, how to we solve the problem raised in notes
    693, 1001, and 1292.
    
    TPU has to ensure that it dispatches events in a timely fashion.  To do
    this even then the TPU application is busy in a long operation (perhaps
    even an infinite loop), TPU has a timer go off every second.  When the
    timer goes off, TPU sets some flags and sends itself a client message. 
    After the timer handler returns the TPU interpreter notices that the
    flags are set and dispatches events.  When it has dispatched all the
    events, it goes back to processing the long operation.
    
                                    August G. Reinig
3328.3OXNARD::KLEEKen LeeTue Sep 11 1990 17:396
    Like I said, there are several ways to safely use signals with Xlib.
    You may want to talk to the PHIGS people, who have an architecture
    similar to yours and are using signals successfully.
    
    Ken
    
3328.4Did so, thanksEVETPU::REINIGThis too shall changeTue Sep 11 1990 18:2042
    I talked to Barry Tannenbaum.  From what he suggested, here's what I'm
    doing:
    
    At startup, on ULTRIX:
    
        env [decw_a_display] = DwtGetDisplay (.env [decw_a_top_widget]);
    	env [decw_a_display2]
	    = XOpenDisplay( XDisplayString (.env [decw_a_display]));

    (Does anyone know if the string returned by XDisplayString has to be
     freed?  The documentation didn't say.)
    
    At signal level, to send a client message to ourselves:
    
        event [x$l_clnt_type] = x$c_client_message;
        event [x$a_clnt_display] = .env [decw_a_display];
        event [x$l_clnt_window] = .env [decw_a_main_window];
        event [x$l_clnt_message_type] = x$c_none;
        event [x$l_clnt_format] = 32;

        !
        ! Send the event - Note that the event mask is bogus.  This is the value
        ! that the session manager uses, and 0 causes a fatal XLIB error
        !
        XSendEvent (.env [decw_a_display2],		! Display2  <=======
		    .env [decw_a_main_window],	! Window
		    false,			! Don't Propagate
		    x$c_client_message,		! Event Mask
		    event [$address]);		! Event
        XFlush (.env [decw_a_display2]);
    
    Also, where ever we have code that uses XEventsQueued to find out the
    number of events queued up we have to check both decw_a_display and
    decw_a_display2.
    
    I hope that this works.
    
                                            August G. Reinig
    
    
    
    
3328.5Don't free DisplayStringLOWELL::KLEINTue Sep 11 1990 19:468
>>    (Does anyone know if the string returned by XDisplayString has to be
>>     freed?  The documentation didn't say.)

Do not free this string.  XDisplayString "calls" the DisplayString macro:

	#define DisplayString(dpy)      ((dpy)->display_name)

-steve-