Branch: Tag:

2002-09-14

2002-09-14 02:58:49 by Martin Stjernholm <mast@lysator.liu.se>

Added fallback to clock() in check_threads if gethrtime doesn't exist, to
avoid very frequent context switches. Put the gethrtime check behind the
divisor check since gethrtime isn't entirely cheap.

Rev: src/threads.c:1.163
Rev: src/threads.h:1.115

1:   /* -  * $Id: threads.h,v 1.114 2002/09/13 19:18:00 mast Exp $ +  * $Id: threads.h,v 1.115 2002/09/14 02:58:49 mast Exp $    */   #ifndef THREADS_H   #define THREADS_H
417:   #define th_hash(X) hashmem((unsigned char *)&(X),sizeof(THREAD_T), 16)   #endif    + #if !defined(HAVE_GETHRTIME) && defined(HAVE_CLOCK) + #ifdef HAVE_TIME_H + #include <time.h> + #endif + PMOD_EXPORT extern clock_t thread_start_clock; + #define USE_CLOCK_FOR_SLICES + #define DO_IF_USE_CLOCK_FOR_SLICES(X) X + #else + #define DO_IF_USE_CLOCK_FOR_SLICES(X) + #endif +    /* Define to get a debug-trace of some of the threads operations. */   /* #define VERBOSE_THREADS_DEBUG 0 */ /* Some debug */   /* #define VERBOSE_THREADS_DEBUG 1 */ /* Lots of debug */
453:   #define SWAP_IN_THREAD(_tmp) do { \    (_tmp)->swapped=0; \    Pike_interpreter=(_tmp)->state; \ +  DO_IF_USE_CLOCK_FOR_SLICES (thread_start_clock = 0); \    DO_IF_PROFILING( Pike_interpreter.time_base -= gethrtime();) \    } while(0)