SunView vs. Lightweight Processes

Scott Weitzenkamp talarian!scott at uunet.uu.net
Sat May 20 15:21:00 AEST 1989


I am writing an application on a Sun 386i running SunOS 4.0.1.  I would
like to use both SunView and lightweight processes.  Can these two be used
together?  I see no mention in the documentation of combining these two
(did I miss something in TFM?).  I have a panel button that executes a
NOTIFY_PROC function (named display_data) which runs for several minutes.
I cannot seem to use notify_dispatch() from within display_data()
callback, as I am in the middle of a callback for several minutes (the
button is still highlighted).  This means my windows become "dead" (no
scrolling or menus or buttons).

I thought this would be a perfect use for the lightweight processes.  I
could have a NOTIFY_PROC function simply create a thread to run
display_data and then return.  I created a notifier thread that looks like
this:

void main_loop_thread() 
{
  static struct timeval sleep_time = {0, 100000};

  window_set(base_frame, WIN_SHOW, TRUE, 0);
  for (;;) {
    notify_dispatch();
    lwp_sleep(&sleep_time);  /* struct timeval sleep_time;
  }
}

This thread is started as soon as I am done creating my windows.  However,
as soon as I start typing into any PANEL_TEXT items, my program hangs.  Do
lightweight processes use signals in a way that the SunView Notifier
cannot stomach?  I tried linking in the non-blocking IO library, but that
made it worse (the first call to window_create would crash the program).

I also though about forking a child process in my NOTIFY_PROC function,
and the child could call display_data() (which updates some text in a
canvas), while the parent could return.  If I fork a child, then I get a
message about the window lock being broken whenever the child writes to
the canvas.

Splitting the program into two separate programs and using IPC is not
feasible at this point because of performance requirements.

I have a kludge working where the NOTIFY_PROC functions simply sets a flag
and returns, and instead of using window_main_loop I use a for loop:

  window_set(base_frame, WIN_SHOW, TRUE, 0);
  for (;;) {
    notify_dispatch();
    if (display_data_flag)  /* set in NOTIFY_PROC */
      display_data();   /* does not return */
    else
      usleep(100000);
   }

This stinks because notify_dispatch only handle one SunView event at a
time, which means my scrolling and buttons look slow and jerky.  Is there
a better way to do this???

Scott Weitzenkamp           UUCP:  uunet!talarian!scott
Talarian Corporation	    ARPA:  farmie at portia.stanford.edu  
"Welcome to the late show, starring NULL and void" -- Men At Work



More information about the Comp.sys.sun mailing list