Busy wait in Getc

From: Keith Wright <kwright_at_tiac.net>
Date: Thu, 19 Sep 96 20:19 EDT

---- I said yesterday:
> I loaded STk for the first time on my Linux machine at home.
> It looked good, and could be useful at work, so I loaded
> it into the computer at work, an HP-UX 9000. I was playing
> with it and it seemed to work, but I got paged by the
> system administrator. It seems that STk had driven the CPU
> load to 99.8% while sitting at the interactive prompt. I
> later checked again on Linux and found that the same thing
> happens there, but since I was the only one using the machine
> I had not noticed it.

I did some poking around in the source and found the follow in
the Getc procedure in Src/io.c:

  #ifdef USE_TK
      if (Tk_initialized) {
        filled = 0;
        while (!filled) {
          Tcl_DoOneEvent(TK_DONT_WAIT);
          if (Tk_GetNumMainWindows() <= 0) return EOF;
        }
      }

that looked wrong so I changed it to:

  #ifdef USE_TK
      if (Tk_initialized) {
        filled = 0;
        while (!filled) {
          Tcl_DoOneEvent(0); /*Tk DO wait!*/
          if (Tk_GetNumMainWindows() <= 0) return EOF;
        }
      }

that seems to work better on both Linux and HP-UX, but I am
tweeking things I don't really understand. What do the grand
wizards say of this?

(by the way, this is VERSION=3.1)
-- 
     --Keith
This mail message sent by GNU emacs and Linux.
Power to the people. Linux is here.
Food, Shelter, Source code.
Received on Fri Sep 20 1996 - 02:23:24 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST