[BACK]Return to irix_threads.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / gc

Diff for /OpenXM_contrib2/asir2000/gc/Attic/irix_threads.c between version 1.3 and 1.4

version 1.3, 2002/07/24 07:46:18 version 1.4, 2002/07/24 08:00:09
Line 21 
Line 21 
  * HP/UX 11.   * HP/UX 11.
  *   *
  * Note that there is a lot of code duplication between linux_threads.c   * Note that there is a lot of code duplication between linux_threads.c
  * and hpux_irix_threads.c; any changes made here may need to be reflected   * and irix_threads.c; any changes made here may need to be reflected
  * there too.   * there too.
  */   */
   
 # if defined(GC_IRIX_THREADS) || defined(IRIX_THREADS)  # if defined(GC_IRIX_THREADS)
   
 # include "private/gc_priv.h"  # include "private/gc_priv.h"
 # include <pthread.h>  # include <pthread.h>
Line 41 
Line 41 
 #undef pthread_join  #undef pthread_join
 #undef pthread_detach  #undef pthread_detach
   
   #ifdef HANDLE_FORK
     --> Not yet supported.  Try porting the code from linux_threads.c.
   #endif
   
 void GC_thr_init();  void GC_thr_init();
   
 #if 0  #if 0
Line 100  GC_thread GC_lookup_thread(pthread_t id);
Line 104  GC_thread GC_lookup_thread(pthread_t id);
  * The only way to suspend threads given the pthread interface is to send   * The only way to suspend threads given the pthread interface is to send
  * signals.  Unfortunately, this means we have to reserve   * signals.  Unfortunately, this means we have to reserve
  * a signal, and intercept client calls to change the signal mask.   * a signal, and intercept client calls to change the signal mask.
    * We use SIG_SUSPEND, defined in gc_priv.h.
  */   */
 # define SIG_SUSPEND (SIGRTMIN + 6)  
   
 pthread_mutex_t GC_suspend_lock = PTHREAD_MUTEX_INITIALIZER;  pthread_mutex_t GC_suspend_lock = PTHREAD_MUTEX_INITIALIZER;
                                 /* Number of threads stopped so far     */                                  /* Number of threads stopped so far     */
Line 141  GC_bool GC_thr_initialized = FALSE;
Line 145  GC_bool GC_thr_initialized = FALSE;
   
 size_t GC_min_stack_sz;  size_t GC_min_stack_sz;
   
 size_t GC_page_sz;  
   
 # define N_FREE_LISTS 25  # define N_FREE_LISTS 25
 ptr_t GC_stack_free_lists[N_FREE_LISTS] = { 0 };  ptr_t GC_stack_free_lists[N_FREE_LISTS] = { 0 };
                 /* GC_stack_free_lists[i] is free list for stacks of    */                  /* GC_stack_free_lists[i] is free list for stacks of    */
Line 171  ptr_t GC_stack_alloc(size_t * stack_size)
Line 173  ptr_t GC_stack_alloc(size_t * stack_size)
     if (result != 0) {      if (result != 0) {
         GC_stack_free_lists[index] = *(ptr_t *)result;          GC_stack_free_lists[index] = *(ptr_t *)result;
     } else {      } else {
         result = (ptr_t) GC_scratch_alloc(search_sz + 2*GC_page_sz);          result = (ptr_t) GC_scratch_alloc(search_sz + 2*GC_page_size);
         result = (ptr_t)(((word)result + GC_page_sz) & ~(GC_page_sz - 1));          result = (ptr_t)(((word)result + GC_page_size) & ~(GC_page_size - 1));
         /* Protect hottest page to detect overflow. */          /* Protect hottest page to detect overflow. */
 #       ifdef STACK_GROWS_UP  #       ifdef STACK_GROWS_UP
           /* mprotect(result + search_sz, GC_page_sz, PROT_NONE); */            /* mprotect(result + search_sz, GC_page_size, PROT_NONE); */
 #       else  #       else
           /* mprotect(result, GC_page_sz, PROT_NONE); */            /* mprotect(result, GC_page_size, PROT_NONE); */
           result += GC_page_sz;            result += GC_page_size;
 #       endif  #       endif
     }      }
     *stack_size = search_sz;      *stack_size = search_sz;
Line 438  void GC_thr_init()
Line 440  void GC_thr_init()
     if (GC_thr_initialized) return;      if (GC_thr_initialized) return;
     GC_thr_initialized = TRUE;      GC_thr_initialized = TRUE;
     GC_min_stack_sz = HBLKSIZE;      GC_min_stack_sz = HBLKSIZE;
     GC_page_sz = sysconf(_SC_PAGESIZE);  
     (void) sigaction(SIG_SUSPEND, 0, &act);      (void) sigaction(SIG_SUSPEND, 0, &act);
     if (act.sa_handler != SIG_DFL)      if (act.sa_handler != SIG_DFL)
         ABORT("Previously installed SIG_SUSPEND handler");          ABORT("Previously installed SIG_SUSPEND handler");
Line 522  int GC_pthread_detach(pthread_t thread)
Line 523  int GC_pthread_detach(pthread_t thread)
     LOCK();      LOCK();
     thread_gc_id = GC_lookup_thread(thread);      thread_gc_id = GC_lookup_thread(thread);
     UNLOCK();      UNLOCK();
     result = REAL_FUNC(pthread_detach)(thread);      result = pthread_detach(thread);
     if (result == 0) {      if (result == 0) {
       LOCK();        LOCK();
       thread_gc_id -> flags |= DETACHED;        thread_gc_id -> flags |= DETACHED;
Line 602  GC_pthread_create(pthread_t *new_thread,
Line 603  GC_pthread_create(pthread_t *new_thread,
     si -> start_routine = start_routine;      si -> start_routine = start_routine;
     si -> arg = arg;      si -> arg = arg;
     LOCK();      LOCK();
     if (!GC_thr_initialized) GC_thr_init();      if (!GC_is_initialized) GC_init();
     if (NULL == attr) {      if (NULL == attr) {
         stack = 0;          stack = 0;
         (void) pthread_attr_init(&new_attr);          (void) pthread_attr_init(&new_attr);
Line 658  VOLATILE GC_bool GC_collecting = 0;
Line 659  VOLATILE GC_bool GC_collecting = 0;
 #define SLEEP_THRESHOLD 3  #define SLEEP_THRESHOLD 3
   
 unsigned long GC_allocate_lock = 0;  unsigned long GC_allocate_lock = 0;
 # define GC_TRY_LOCK() !GC_test_and_set(&GC_allocate_lock,1)  # define GC_TRY_LOCK() !GC_test_and_set(&GC_allocate_lock)
 # define GC_LOCK_TAKEN GC_allocate_lock  # define GC_LOCK_TAKEN GC_allocate_lock
   
 void GC_lock()  void GC_lock()
Line 725  yield:
Line 726  yield:
   int GC_no_Irix_threads;    int GC_no_Irix_threads;
 #endif  #endif
   
 # endif /* IRIX_THREADS */  # endif /* GC_IRIX_THREADS */
   

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>