Branch: Tag:

2000-04-19

2000-04-19 16:14:37 by Martin Stjernholm <mast@lysator.liu.se>

Better debug checks on the interpreter lock.

Rev: src/interpret.c:1.144
Rev: src/interpreter.h:1.41
Rev: src/modules/HTTPLoop/accept_and_parse.c:1.12
Rev: src/modules/HTTPLoop/cache.c:1.9
Rev: src/modules/Java/jvm.c:1.15
Rev: src/modules/files/file.c:1.174
Rev: src/modules/files/sendfile.c:1.38
Rev: src/program.c:1.229
Rev: src/signal_handler.c:1.169
Rev: src/threads.c:1.122
Rev: src/threads.h:1.86

1:   #include "global.h" - RCSID("$Id: threads.c,v 1.121 2000/04/19 13:57:36 mast Exp $"); + RCSID("$Id: threads.c,v 1.122 2000/04/19 16:03:31 mast Exp $");      int num_threads = 1;   int threads_disabled = 0;
201:   int thread_id_result_variable;      int th_running = 0; + #ifdef PIKE_DEBUG + int debug_interpreter_is_locked = 0; + THREAD_T debug_locking_thread; + #endif   MUTEX_T interpreter_lock, thread_table_lock, interleave_lock;   struct program *mutex_key = 0;   struct program *thread_id_prog = 0;
292:    (stderr,    "_disable_threads(): Waiting for %d threads to finish\n",    live_threads)); -  co_wait(&live_threads_change, &interpreter_lock); +  co_wait_interpreter(&live_threads_change);    }    SWAP_IN_CURRENT_THREAD();    }
559:    THREADS_FPRINTF(0, (stderr,"THREADS_DISALLOW() Thread %08x created...\n",    (unsigned int)arg.id));    -  if((tmp=mt_lock( & interpreter_lock))) +  if((tmp=mt_lock_interpreter()))    fatal("Failed to lock interpreter, return value=%d, errno=%d\n",tmp,   #ifdef __NT__    GetLastError()
654:    remove_callback(threads_evaluator_callback);    threads_evaluator_callback=0;    } -  mt_unlock(& interpreter_lock); +  mt_unlock_interpreter();    th_exit(0);    /* NOT_REACHED, but removes a warning */    return(NULL);
803:    do    {    THREADS_FPRINTF(1, (stderr,"WAITING TO LOCK m:%08x\n",(unsigned int)m)); -  co_wait(& m->condition, & interpreter_lock); +  co_wait_interpreter(& m->condition);    }while(m->key);    SWAP_IN_CURRENT_THREAD();    }
969:       /* Wait and allow mutex operations */    SWAP_OUT_CURRENT_THREAD(); -  co_wait(c, &interpreter_lock); +  co_wait_interpreter(c);       /* Lock mutex */    while(mut->key) -  co_wait(& mut->condition, &interpreter_lock); +  co_wait_interpreter(& mut->condition);    mut->key=key;    OB2KEY(key)->mut=mut;   
984:    }       SWAP_OUT_CURRENT_THREAD(); -  co_wait(c, &interpreter_lock); +  co_wait_interpreter(c);    SWAP_IN_CURRENT_THREAD();       pop_n_elems(args);
1040:    SWAP_OUT_CURRENT_THREAD();       while(th->status != THREAD_EXITED) -  co_wait(&th->status_change, &interpreter_lock); +  co_wait_interpreter(&th->status_change);       SWAP_IN_CURRENT_THREAD();   
1166:   #endif /* POSIX_THREADS */       mt_init( & interpreter_lock); -  mt_lock( & interpreter_lock); +  mt_lock_interpreter();    mt_init( & thread_table_lock);    mt_init( & interleave_lock);    co_init( & live_threads_change);