pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1488:    sys.tv_usec = info.system_time.microseconds;    timeradd (&user, &sys, &now);    timersub(&now, &last_check, &diff);    if (diff.tv_usec < 50000 && diff.tv_sec == 0)    return;    last_check = now;   #endif    }    }   #elif defined (USE_CLOCK_FOR_SLICES) -  if (clock() - thread_start_clock < (clock_t) (CLOCKS_PER_SEC / 20)) +  { +  clock_t clock_now = clock(); +  if (clock_now - thread_start_clock < 0) +  /* clock counter has wrapped since the start of the time slice. +  * Let's reset and yield. */ +  thread_start_clock = 0; +  else if (clock_now - thread_start_clock < (clock_t) (CLOCKS_PER_SEC / 20))    return; -  +  }   #else    static int div_;    if(div_++ & 255)    return;   #endif       do_yield:;      #ifdef PROFILE_CHECK_THREADS    {