pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: threads.c,v 1.199 2003/10/06 13:01:37 mast Exp $ + || $Id: threads.c,v 1.200 2003/12/10 13:01:18 jonasw Exp $   */      #include "global.h" - RCSID("$Id: threads.c,v 1.199 2003/10/06 13:01:37 mast Exp $"); + RCSID("$Id: threads.c,v 1.200 2003/12/10 13:01:18 jonasw Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "mapping.h"   #include "object.h"   #include "pike_macros.h"
pike.git/src/threads.c:30:   #include "bignum.h"   #include "signal_handler.h"   #include "rusage.h"      #include <errno.h>      #ifdef HAVE_SYS_PRCTL_H   #include <sys/prctl.h>   #endif /* HAVE_SYS_PRCTL_H */    + #ifdef HAVE_SYS_TIME_H + #include <sys/time.h> + #endif +    #ifndef PIKE_THREAD_C_STACK_SIZE   #define PIKE_THREAD_C_STACK_SIZE (256 * 1024)   #endif      PMOD_EXPORT int live_threads = 0, disallow_live_threads = 0;   PMOD_EXPORT COND_T live_threads_change;   PMOD_EXPORT COND_T threads_disabled_change;   PMOD_EXPORT size_t thread_stack_size=PIKE_THREAD_C_STACK_SIZE;      PMOD_EXPORT void thread_low_error (int errcode)
pike.git/src/threads.c:645: Inside #if undefined(HAVE_NO_YIELD)
   if(div_++ & 255)    return;   #ifdef HAVE_GETHRTIME    {    static hrtime_t last_ = 0;    hrtime_t now = gethrtime();    if( now-last_ < 50000000 ) /* 0.05s slice */    return;    last_ = now;    } + #elif defined(HAVE_MACH_TASK_INFO_H) && defined(TASK_THREAD_TIMES_INFO) +  { +  static struct timeval last_check = { 0, 0 }; +  task_thread_times_info_data_t info; +  mach_msg_type_number_t info_size = TASK_THREAD_TIMES_INFO_COUNT; +  +  /* Get user time and test if 50usec has passed since last check. */ +  if (task_info(mach_task_self(), TASK_THREAD_TIMES_INFO, +  (task_info_t) &info, &info_size) == 0) { +  /* Compute difference by converting kernel time_info_t to timeval. */ +  struct timeval now; +  struct timeval diff; +  now.tv_sec = info.user_time.seconds; +  now.tv_usec = info.user_time.microseconds; +  timersub(&now, &last_check, &diff); +  if (diff.tv_usec < 50000 && diff.tv_sec == 0) +  return; +  last_check = now; +  } +  }   #elif defined (USE_CLOCK_FOR_SLICES)    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) {    debug_list_all_threads();    Pike_fatal("thread_for_id() (or Pike_interpreter.thread_id) failed! %p != %p\n",thread_for_id(th_self()),Pike_interpreter.thread_id) ;