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.201 2004/04/21 19:25:23 mast Exp $ + || $Id: threads.c,v 1.202 2004/04/23 19:35:28 grubba Exp $   */      #include "global.h" - RCSID("$Id: threads.c,v 1.201 2004/04/21 19:25:23 mast Exp $"); + RCSID("$Id: threads.c,v 1.202 2004/04/23 19:35:28 grubba Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;      /* #define PICKY_MUTEX */      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "mapping.h"
pike.git/src/threads.c:1307:    THREADS_FPRINTF(1, (stderr, "UNLOCK k:%08x m:(%08x) t:%08x o:%08x\n",    (unsigned int)THIS_KEY,    (unsigned int)THIS_KEY->mut,    (unsigned int)Pike_interpreter.thread_id,    (unsigned int)THIS_KEY->owner));    if(THIS_KEY->mut)    {    struct mutex_storage *mut = THIS_KEY->mut;      #ifdef PIKE_DEBUG -  if(mut->key != o) -  Pike_fatal("Mutex unlock from wrong key %p != %p!\n",THIS_KEY->mut->key,o); +  /* Note: mut->key can be NULL if our corresponding mutex +  * has been destructed. +  */ +  if(mut->key && (mut->key != o)) +  Pike_fatal("Mutex unlock from wrong key %p != %p!\n", mut->key, o);   #endif    mut->key=0;    if (THIS_KEY->owner) {    free_object(THIS_KEY->owner);    THIS_KEY->owner=0;    }    THIS_KEY->mut=0;    THIS_KEY->initialized=0;    if (mut->num_waiting)    co_signal(& mut->condition);
pike.git/src/threads.c:1397:    if(args > 1) {    pop_n_elems(args - 1);    args = 1;    }       c = THIS_COND;       /* Unlock mutex */    mut->key=0;    OB2KEY(key)->mut=0; +  mut->num_waiting++;    co_signal(& mut->condition);       /* Wait and allow mutex operations */    SWAP_OUT_CURRENT_THREAD();    co_wait_interpreter(c);    SWAP_IN_CURRENT_THREAD();       /* Lock mutex */    while(mut->key) {    SWAP_OUT_CURRENT_THREAD();    co_wait_interpreter(& mut->condition);    SWAP_IN_CURRENT_THREAD();    check_threads_etc();    }    mut->key=key;    OB2KEY(key)->mut=mut; -  +  mut->num_waiting--;       pop_stack();    return;   }      /*! @decl void signal()    *!    *! @[signal()] wakes up one of the threads currently waiting for the    *! condition.    *!