Branch: Tag:

2002-09-14

2002-09-14 03:03:05 by Martin Stjernholm <mast@lysator.liu.se>

Ported some thread yielding improvements from 7.3.

Rev: src/threads.c:1.164
Rev: src/threads.h:1.116

1:   #include "global.h" - RCSID("$Id: threads.c,v 1.163 2002/09/14 02:58:49 mast Exp $"); + RCSID("$Id: threads.c,v 1.164 2002/09/14 03:03:04 mast Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;
547:      static void check_threads(struct callback *cb, void *arg, void * arg2)   { + #ifndef HAVE_NO_YIELD +  /* If we have no yield we can't cut calls here since it's possible +  * that a thread switch will take place only occasionally in the +  * window below. */    static int div_;    if(div_++ & 255)    return;
562:    if (clock() - thread_start_clock < (clock_t) (CLOCKS_PER_SEC / 20))    return;   #endif + #endif      #ifdef DEBUG    if(thread_for_id(th_self()) != Pike_interpreter.thread_id)
573:       THREADS_ALLOW();    /* Allow other threads to run */ - #ifdef HAVE_THR_YIELD -  thr_yield(); - #endif +  th_yield();    THREADS_DISALLOW();      #ifdef USE_CLOCK_FOR_SLICES