Skip to content
Tcl Source Code History Of Ticket 411603ffffffffff
Login

History Of Ticket 411603ffffffffff

Artifacts Associated With Ticket 411603ffffffffff

  1. Ticket change [523ddc910a] (rid 126280) by ruppert on 2001-03-27 10:49:31:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      
      Hi,
      
      a collegue of mine has debugged a strange behaviour of
      a
      Tk script which was executed in a Tcl interpreter with
      threads enabled under Solaris 2.6. We observed that
      even
      trivial scripts which include an entry widget with a
      blinking
      cursor drive the cpu load to substantial values (up to
      100%
      on smaller workstations, i.e. Sparcstation 5), as long
      as
      the cursor is blinking!
      
      This can be reproduced with the following trivial
      script:
      
        entry .entry -bg white -relief sunken
        pack .entry -side left -fill x -expand yes
      
      To reproduce: Execute these two lines in a wish which
      has been 
      built with --enable-scripts, click into the entry
      widget (which
      makes the cursor start blinking) and observe the cpu
      load in
      a perfmeter.
      
      We could reproduce this with Tk versions 8.3.0, 8.3.2
      and 8.4a2
      on Solaris 2.6; a collegue reproduced this also on a
      Linux box.
      
      After some extensive debugging, the ultimate reason for
      this
      was found: a timeout value in Tcl_ConditionWait
      (tclUnixThrd.c)
      is computed in a way which is, for timeout values <
      1sec, almost
      always incorrect:
      
      ------------------------------------------------------------------
        void
        Tcl_ConditionWait(condPtr, mutexPtr, timePtr)
          Tcl_Condition *condPtr;/* Really (pthread_cond_t
      **) */
          Tcl_Mutex *mutexPtr;/* Really (pthread_mutex_t **)
      */
          Tcl_Time *timePtr;/* Timeout on waiting period */
        {
          pthread_cond_t *pcondPtr;
          pthread_mutex_t *pmutexPtr;
          struct timespec ptime;
      
          if (*condPtr == NULL) {
      MASTER_LOCK;
      
      /* 
       * Double check inside mutex to avoid race,
       * then initialize condition variable if necessary.
       */
      
      if (*condPtr == NULL) {
          pcondPtr = (pthread_cond_t
      *)ckalloc(sizeof(pthread_cond_t));
          pthread_cond_init(pcondPtr, NULL);
          *condPtr = (Tcl_Condition)pcondPtr;
          TclRememberCondition(condPtr);
      }
      MASTER_UNLOCK;
          }
          pmutexPtr = *((pthread_mutex_t **)mutexPtr);
          pcondPtr = *((pthread_cond_t **)condPtr);
          if (timePtr == NULL) {
      pthread_cond_wait(pcondPtr, pmutexPtr);
          } else {
      ptime.tv_sec = timePtr->sec + TclpGetSeconds();     
      <------
      ptime.tv_nsec = 1000 * timePtr->usec;               
      <------
      pthread_cond_timedwait(pcondPtr, pmutexPtr, &ptime);
          }
        }
      ---------------------------------------------------------------
      
      Explanation: the lines marked with the arrows attempt
      to calculate
      a time value from a desired time interval (*timePtr),
      which is composed
      from seconds and microseconds, and the current time,
      which is obtained with TclpGetSeconds, thus completely
      ignoring fractions
      of a second. 
      
      Assume a desired timeout value of 300 ms, which is the
      default value
      for cursor blinking, scrollbar repeat rates etc. in Tk:
      timePtr->sec
      is zero, and timePtr->usec is 300000. ptime.tv_sec (the
      desired
      "firing time" of pthread_cond_timedwait) will thus
      always be the "current"
      second value, and ptime.tv_nsec corresponds to 300 ms.
      Therefore, 70%
      of the time, pthread_cond_timedwait will return
      immediately. 
      Because this code is invoked from a loop waiting for
      events in situations
      when a blinking cursor has to be updated, the function
      Tcl_ConditionWait almost never really waits, but
      instead executes
      more or less permanently, as long as the cursor is
      blinking, thus leading 
      to the observed cpu load values.
      
      Suggested fix: the timeout value needs to correctly
      take into account
      the microsecond component of the current time,
      including possible overflow
      situations when microsecond values add up to > 1000000.
      We suggest to
      replace the above two lines with the following:
      
      Tcl_Time now;
      TclpGetTime(&now);
      ptime.tv_sec = timePtr->sec + now.sec + ( timePtr->usec
      + now.usec ) / 1000000;
      ptime.tv_nsec = 1000 * (( timePtr->usec + now.usec ) %
      1000000);
      
      We have tried this fix, and this has removed the
      problem completely.
      
      Best Regards
      D.Ruppert
      RTS GmbH
      Schwieberdingen/Germany
      [email protected]
      
      
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "ruppert"
    9. subsystem initialized to: "49. Threading"
    10. title initialized to: "timeout bug in tclUnixThrd.c"
    11. type initialized to: "Bug"
  2. Ticket change [7b47e8305c] (rid 90493) by hobbs on 2001-03-28 08:03:59:

    1. assignee changed to: "hobbs"
    2. closedate changed to: "2001-03-28T01:03:59"
    3. closer changed to: "hobbs"
    4. icomment:
      Logged In: YES 
      user_id=72656
      
      patched as noted for 8.4a2, see patch 411773.
      
      
    5. login: "hobbs"
    6. mimetype: "text/plain"
    7. status changed to: "Closed"
    8. username: "hobbs"
  3. Ticket change [551b703031] (rid 94072) by hobbs on 2001-03-28 08:04:58:

    1. closedate changed to: "2001-03-28T01:04:58"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      
      patched as noted for 8.4a2, see patch 411773.
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. username: "hobbs"
  4. Ticket change [a5085bfad3] (rid 110305) by hobbs on 2001-03-28 08:13:04:

    1. closedate changed to: "2001-03-28T01:13:04"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      
      patched as noted for 8.4a2, see patch 411773.
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. username: "hobbs"
  5. Ticket change [8e085bbf17] (rid 120047) by hobbs on 2001-03-28 08:54:34:

    1. closedate changed to: "2001-03-28T01:54:34"
    2. closer changed to: "hobbs"
    3. icomment:
      Logged In: YES 
      user_id=72656
      
      patched as noted for 8.4a2, see patch 411773.
      
      
    4. login: "hobbs"
    5. mimetype: "text/plain"
    6. username: "hobbs"
  6. Ticket change [9dd320eb0e] (rid 96376) by dgp on 2001-03-30 04:53:21:

    1. closedate changed to: "2001-03-29T21:53:21"
    2. closer changed to: "dgp"
    3. resolution changed to: "Fixed"