Ruby 1.9.3p327(2012-11-10revision37606)
thread_pthread.h
Go to the documentation of this file.
00001 /**********************************************************************
00002 
00003   thread_pthread.h -
00004 
00005   $Author: kosaki $
00006 
00007   Copyright (C) 2004-2007 Koichi Sasada
00008 
00009 **********************************************************************/
00010 
00011 #ifndef RUBY_THREAD_PTHREAD_H
00012 #define RUBY_THREAD_PTHREAD_H
00013 
00014 #include <pthread.h>
00015 #ifdef HAVE_PTHREAD_NP_H
00016 #include <pthread_np.h>
00017 #endif
00018 typedef pthread_t rb_thread_id_t;
00019 typedef pthread_mutex_t rb_thread_lock_t;
00020 
00021 typedef struct rb_thread_cond_struct {
00022     pthread_cond_t cond;
00023 #ifdef HAVE_CLOCKID_T
00024     clockid_t clockid;
00025 #endif
00026 } rb_thread_cond_t;
00027 
00028 typedef struct native_thread_data_struct {
00029     void *signal_thread_list;
00030     rb_thread_cond_t sleep_cond;
00031 } native_thread_data_t;
00032 
00033 #include <semaphore.h>
00034 
00035 typedef struct rb_global_vm_lock_struct {
00036     /* fast path */
00037     unsigned long acquired;
00038     pthread_mutex_t lock;
00039 
00040     /* slow path */
00041     volatile unsigned long waiting;
00042     rb_thread_cond_t cond;
00043 
00044     /* yield */
00045     rb_thread_cond_t switch_cond;
00046     rb_thread_cond_t switch_wait_cond;
00047     int need_yield;
00048     int wait_yield;
00049 } rb_global_vm_lock_t;
00050 
00051 #endif /* RUBY_THREAD_PTHREAD_H */
00052