Branch: Tag:

2003-12-10

2003-12-10 13:01:18 by 0

Backported Mac OS X fixes and performance improvements from 7.5: We now use
pthread_wait_np() and use Mach kernel calls to greatly reduce thread
scheduling overhead. Included OSF/1 fixes by Grubba.

Rev: src/acconfig.h:1.113
Rev: src/configure.in:1.671
Rev: src/pike_threadlib.h:1.28
Rev: src/threads.c:1.200

2:   || 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;
37:   #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
652: Inside #if undefined(HAVE_NO_YIELD) and #if defined(HAVE_GETHRTIME)
   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;