pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:2511: Inside #if undefined(PICKY_MUTEX)
  #endif    co_destroy(& m->condition);    }   #else    if(key) {    m->key=0;    destruct(key); /* Will destroy m->condition if m->num_waiting is zero. */    if(m->num_waiting)    {    THREADS_FPRINTF(1, (stderr, "Destructed mutex is being waited on.\n")); +  THREADS_ALLOW();    /* exit_mutex_key_obj has already signalled, but since the    * waiting threads will throw an error instead of making a new    * lock we need to double it to a broadcast. The last thread    * that stops waiting will destroy m->condition. */    co_broadcast (&m->condition); -  +  +  /* Try to wake up the waiting thread(s) immediately +  * in an attempt to avoid starvation. +  */ + #ifdef HAVE_NO_YIELD +  sleep(0); + #else /* HAVE_NO_YIELD */ +  th_yield(); + #endif /* HAVE_NO_YIELD */ +  THREADS_DISALLOW();    }    }    else {    co_destroy(& m->condition);    }   #endif   }      void exit_mutex_obj_compat_7_4(struct object *UNUSED(o))   {
pike.git/src/threads.c:2605:    THIS_KEY->owner = NULL;    }    if (THIS_KEY->owner_obj) {    free_object(THIS_KEY->owner_obj);    THIS_KEY->owner_obj=0;    }    THIS_KEY->mut=0;    THIS_KEY->initialized=0;    mutex_obj = THIS_KEY->mutex_obj;    THIS_KEY->mutex_obj = NULL; -  if (mut->num_waiting) +  +  if (mut->num_waiting) { +  THREADS_ALLOW();    co_signal(&mut->condition); -  else if (mutex_obj && !mutex_obj->prog) { +  +  /* Try to wake up the waiting thread(s) immediately +  * in an attempt to avoid starvation. +  */ + #ifdef HAVE_NO_YIELD +  sleep(0); + #else /* HAVE_NO_YIELD */ +  th_yield(); + #endif /* HAVE_NO_YIELD */ +  THREADS_DISALLOW(); +  } else if (mutex_obj && !mutex_obj->prog) {    co_destroy (&mut->condition);    } -  +     if (mutex_obj)    free_object(mutex_obj);    }   }      /*! @endclass    */      /*! @class Condition    *!