pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.63 1998/03/25 18:53:09 grubba Exp $"); + RCSID("$Id: threads.c,v 1.64 1998/03/26 05:48:24 per Exp $");      int num_threads = 1;   int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "object.h"   #include "pike_macros.h"   #include "callback.h"
pike.git/src/threads.c:145: Inside #if defined(POSIX_THREADS)
  pthread_attr_t pattr;   pthread_attr_t small_pattr;   #endif      struct thread_starter   {    struct object *id;    struct array *args;   };    - int threads_denied; + void exit_threads_disable(struct object *o) + { +  if(threads_disabled) threads_disabled--; + }    - void f_thread_disallow(INT32 args) + void init_threads_disable(struct object *o)   { -  threads_denied = sp[-1].u.integer; -  pop_n_elems(args); +  threads_disabled++;   }      /* Thread hashtable */      #define THREAD_TABLE_SIZE 127 /* Totally arbitrary prime */      static struct thread_state *thread_table_chains[THREAD_TABLE_SIZE];      void thread_table_init()   {
pike.git/src/threads.c:272:    mt_unlock( & thread_table_lock );    f_aggregate(sp-oldsp);   }         static void check_threads(struct callback *cb, void *arg, void * arg2)   {    static int div_;    if(div_++ & 255) return;    -  if(!threads_denied) -  { +     THREADS_ALLOW(); -  +     /* Allow other threads to run */ -  +     THREADS_DISALLOW();   } - } +       void *new_thread_func(void * data)   {    struct thread_starter arg = *(struct thread_starter *)data;    JMP_BUF back;    INT32 tmp;       THREADS_FPRINTF((stderr,"THREADS_DISALLOW() Thread %08x created...\n",    (unsigned int)arg.id));   
pike.git/src/threads.c:735: Inside #if defined(POSIX_THREADS)
   pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_DETACHED);       pthread_attr_init(&small_pattr);   #ifdef HAVE_PTHREAD_ATTR_SETSTACKSIZE    pthread_attr_setstacksize(&small_pattr, 32768);   #endif    pthread_attr_setdetachstate(&small_pattr, PTHREAD_CREATE_DETACHED);      #endif    -  add_efun("thread_disallow", f_thread_disallow, "function(int:void)", -  OPT_SIDE_EFFECT); -  +     add_efun("thread_create",f_thread_create,"function(mixed ...:object)",    OPT_SIDE_EFFECT);   #ifdef UNIX_THREADS    add_efun("thread_set_concurrency",f_thread_set_concurrency,    "function(int:void)", OPT_SIDE_EFFECT);   #endif    add_efun("this_thread",f_this_thread,"function(:object)",    OPT_EXTERNAL_DEPEND);    add_efun("all_threads",f_all_threads,"function(:array(object))",    OPT_EXTERNAL_DEPEND);
pike.git/src/threads.c:782:       start_new_program();    add_storage(sizeof(COND_T));    add_function("wait",f_cond_wait,"function(void|object:void)",0);    add_function("signal",f_cond_signal,"function(:void)",0);    add_function("broadcast",f_cond_broadcast,"function(:void)",0);    set_init_callback(init_cond_obj);    set_exit_callback(exit_cond_obj);    end_class("condition", 0);    +  { +  struct program *tmp;    start_new_program(); -  +  set_init_callback(init_threads_disable); +  set_exit_callback(exit_threads_disable); +  tmp = end_program(); +  tmp->flags|=PROGRAM_DESTRUCT_IMMEDIATE; +  add_global_program("_disable_threads", tmp); +  } +  +  start_new_program();    add_storage(sizeof(struct thread_state));    thread_id_result_variable=simple_add_variable("result","mixed",0);    add_function("backtrace",f_thread_backtrace,"function(:array)",0);    add_function("wait",f_thread_id_result,"function(:mixed)",0);    add_function("status",f_thread_id_status,"function(:int)",0);   #ifdef DEBUG    set_gc_mark_callback(thread_was_marked);   #endif    set_init_callback(init_thread_obj);    set_exit_callback(exit_thread_obj);