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.274 2009/01/26 10:15:06 grubba Exp $ + || $Id: threads.c,v 1.275 2009/03/13 16:22:31 mast Exp $   */      #include "global.h"      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;      /* #define PICKY_MUTEX */      #ifdef _REENTRANT
pike.git/src/threads.c:340:   PMOD_EXPORT unsigned long thread_yields = 0;   #endif   PMOD_EXPORT MUTEX_T interpreter_lock;   MUTEX_T thread_table_lock, interleave_lock;   struct program *mutex_key = 0;   PMOD_EXPORT struct program *thread_id_prog = 0;   struct program *thread_local_prog = 0;   PMOD_EXPORT ptrdiff_t thread_storage_offset;   #ifdef USE_CLOCK_FOR_SLICES   PMOD_EXPORT clock_t thread_start_clock = 0; + PMOD_EXPORT THREAD_T last_clocked_thread = 0;   #endif      #ifdef PIKE_DEBUG   PMOD_EXPORT const char msg_ip_not_locked[] =    "Interpreter not locked.\n";   PMOD_EXPORT const char msg_ip_not_locked_this_thr[] =    "Interpreter not locked by this thread.\n";   PMOD_EXPORT const char msg_thr_swapped_over[] =    "Thread 0x%08x swapped in over existing thread 0x%08x.\n";   PMOD_EXPORT const char msg_saved_thread_id[] =
pike.git/src/threads.c:918: Inside #if undefined(HAVE_NO_YIELD)
   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) + #ifdef PIKE_DEBUG +  if (last_clocked_thread != th_self()) +  Pike_fatal ("Stale thread %08lx in last_clocked_thread (self is %08lx)\n", +  (unsigned long) last_clocked_thread, (unsigned long) th_self()); + #endif    if (clock() - thread_start_clock < (clock_t) (CLOCKS_PER_SEC / 20))    return;   #else    static int div_;    if(div_++ & 255)    return;   #endif   #endif      #ifdef PROFILE_CHECK_THREADS
pike.git/src/threads.c:949:   #endif       DEBUG_CHECK_THREAD();       THREADS_ALLOW();    /* Allow other threads to run */    th_yield();    THREADS_DISALLOW();      #ifdef USE_CLOCK_FOR_SLICES -  /* Must set the base time for the slice here since clock() returns -  * thread local time. */ +  /* If we didn't yield then give ourselves a new time slice. If we +  * did yield then thread_start_clock is the current clock anyway +  * after the thread swap in. */    thread_start_clock = clock(); -  + #ifdef PIKE_DEBUG +  if (last_clocked_thread != th_self()) +  Pike_fatal ("Stale thread %08lx in last_clocked_thread (self is %08lx)\n", +  (unsigned long) last_clocked_thread, (unsigned long) th_self());   #endif -  + #endif       DEBUG_CHECK_THREAD();   }      struct thread_starter   {    struct thread_state *thread_state; /* State of the thread. */    struct array *args; /* Arguments passed to the thread. */   #ifdef HAVE_BROKEN_LINUX_THREAD_EUID    int euid, egid;