OSSP CVS Repository

ossp - Ticket #154 History
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Attach]  [Edit]  [View

Ticket 154 History: pth_scheduler_load in uninterruptible loop if time is adjusted forward

  1. Created 2007-Mar-28 02:48:18 by anonymous
  2. Added remarks:
    I noticed a logic flaw in the patch for detecting backwards discontinuity in time. Here is an updated patch:


      --- pth-2.0.7.orig/pth_sched.c	2006-06-08 10:54:03.000000000 -0700
      +++ pth-2.0.7/pth_sched.c	2007-03-28 10:43:30.000000000 -0700
      @@ -137,12 +137,25 @@
        * been occurred and we would have been given more chances to operate).
        * The actual average load is calculated through an exponential average
        * formula.
      + *
      + * If the system clock is adjusted forward by more than 10 seconds,
      + * or if the system clock is adjusted backwards, the load average is
      + * reset to the current load.
        */
      -#define pth_scheduler_load(now) \
      -    if (pth_time_cmp((now), &pth_loadticknext) >= 0) { \
      -        pth_time_t ttmp; \
      -        int numready; \
      -        numready = pth_pqueue_elements(&pth_RQ); \
      +
      +#define pth_scheduler_load(now) { \
      +    pth_time_t ttmp; \
      +    pth_time_t ten_sec = PTH_TIME(10,0); \
      +    int numready; \
      +    numready = pth_pqueue_elements(&pth_RQ); \
      +    pth_time_set(&ttmp, (now)); \
      +    pth_time_add(&ttmp, &pth_loadtickgap); \
      +    pth_time_sub(&ttmp, &pth_loadticknext); \
      +    if ((pth_time_cmp(&ttmp, &ten_sec) >= 0) || !pth_time_pos(&ttmp)) { \
      +         pth_loadval = numready; \
      +        pth_time_set(&pth_loadticknext, (now)); \
      +        pth_time_add(&pth_loadticknext, &pth_loadtickgap); \
      +    } else if (pth_time_cmp((now), &pth_loadticknext) >= 0) { \
               pth_time_set(&ttmp, (now)); \
               do { \
                   pth_loadval = (numready*0.25) + (pth_loadval*0.75); \
      @@ -150,7 +163,8 @@
               } while (pth_time_cmp(&ttmp, &pth_loadticknext) >= 0); \
               pth_time_set(&pth_loadticknext, (now)); \
               pth_time_add(&pth_loadticknext, &pth_loadtickgap); \
      -    }
      +    } \
      +}
    

       /* the heart of this library: the thread scheduler */
       intern void *pth_scheduler(void *dummy)
    


    - Edwin
    by anonymous on 2007-Mar-28 20:12

CVSTrac 2.0.1