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.241 2004/12/30 13:50:35 grubba Exp $ + || $Id: threads.c,v 1.242 2005/01/25 18:58:02 grubba Exp $   */      #ifndef CONFIGURE_TEST   #include "global.h"      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;   #endif /* !CONFIGURE_TEST */      /* #define PICKY_MUTEX */
pike.git/src/threads.c:823: Inside #if defined(PIKE_DEBUG)
   if(d_flag) {    THREAD_T self = th_self();    if( !th_equal(arg.thread_state->id, self) )    Pike_fatal("Current thread is wrong. %lx %lx\n",    (long)arg.thread_state->id, (long)self);    }   #endif       arg.thread_state->swapped = 0;    Pike_interpreter = arg.thread_state->state; -  init_interpreter(); +       #ifdef PROFILING    Pike_interpreter.stack_bottom=((char *)&data);   #endif    Pike_interpreter.stack_top=((char *)&data)+ (thread_stack_size-16384) * STACK_DIRECTION;    Pike_interpreter.recoveries = NULL;       add_ref(thread_obj = arg.thread_state->thread_obj);    INIT_THREAD_STATE(thread_state = arg.thread_state);   
pike.git/src/threads.c:881:    }       thread_state->status = THREAD_EXITED;    co_broadcast(&thread_state->status_change);       THREADS_FPRINTF(0, (stderr,"new_thread_func(): Thread %p done\n",    arg.thread_state));       /* This thread is now officially dead. */    -  cleanup_interpret(); +  while(Pike_fp) +  POP_PIKE_FRAME();    -  +  reset_evaluator(); +  +  low_cleanup_interpret(&thread_state->state); +     thread_table_delete(thread_state);    EXIT_THREAD_STATE(thread_state);    Pike_interpreter.thread_state = thread_state = NULL;       /* Free ourselves.    * NB: This really ought to run in some other thread...    */       free_object(thread_obj);    thread_obj = NULL;
pike.git/src/threads.c:958:    int tmp;       if (thread_state->status != THREAD_NOT_STARTED) {    Pike_error("Threads can not be restarted (status:%d).\n",    thread_state->status);    }       arg.args = aggregate_array(args);    arg.thread_state = thread_state;    +  if (low_init_interpreter(&thread_state->state)) { +  free_array(arg.args); +  Pike_error("Out of memory allocating stack.\n"); +  } +    #ifdef HAVE_BROKEN_LINUX_THREAD_EUID    arg.euid = geteuid();    arg.egid = getegid();   #endif /* HAVE_BROKEN_LINUX_THREAD_EUID */       do {    tmp = th_create(&thread_state->id,    new_thread_func,    &arg);    if (tmp == EINTR) check_threads_etc();
pike.git/src/threads.c:998:    * before we exit the function...    */    SWAP_OUT_CURRENT_THREAD();    while (thread_state->status == THREAD_NOT_STARTED) {    THREADS_FPRINTF(0, (stderr, "THREAD_CREATE %p waiting...\n",    thread_state));    low_co_wait_interpreter(&thread_state->status_change);    }    SWAP_IN_CURRENT_THREAD();    } else { +  low_cleanup_interpret(&thread_state->state);    free_array(arg.args);    Pike_error("Failed to create thread (errno = %d).\n", tmp);    }       THREADS_FPRINTF(0, (stderr, "THREAD_CREATE -> t:%08x\n",    (unsigned int)thread_state));    push_int(0);   }      /*! @endclass
pike.git/src/threads.c:1481:    *! Condition variables are only available on systems with thread    *! support. The Condition class is not simulated otherwise, since that    *! can't be done accurately without continuations.    *!    *! @seealso    *! @[Mutex]    */      /*! @decl void wait(Thread.MutexKey mutex_key)    *! -  *! Wait for contition. +  *! Wait for condition.    *!    *! This function makes the current thread sleep until the condition    *! variable is signalled. The argument should be a @[Thread.MutexKey]    *! object for a @[Thread.Mutex]. It will be unlocked atomically    *! before waiting for the signal and then relocked atomically when    *! the signal is received.    *!    *! The thread that sends the signal should have the mutex locked    *! while sending it. Otherwise it's impossible to avoid races where    *! signals are sent while the listener(s) haven't arrived to the