thread_pthread.c File Reference

#include "gc.h"

Go to the source code of this file.

Data Structures

struct  cached_thread_entry

Defines

#define RB_CONDATTR_CLOCK_MONOTONIC   1
#define USE_MONOTONIC_COND   0
#define USE_SLEEPY_TIMER_THREAD   0
#define ARRAY_SIZE(x)   (sizeof(x) / sizeof((x)[0]))
#define NATIVE_MUTEX_LOCK_DEBUG   0
#define TIMET_MAX   (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0))
#define native_cleanup_push   pthread_cleanup_push
#define native_cleanup_pop   pthread_cleanup_pop
#define native_thread_yield()   ((void)0)
#define USE_THREAD_CACHE   0
#define MAINSTACKADDR_AVAILABLE   0
#define CHECK_ERR(expr)   {int err = (expr); if (err) {rb_bug_errno(#expr, err);}}
#define USE_NATIVE_THREAD_INIT   1
#define add_signal_thread_list(th)   (void)(th)
#define remove_signal_thread_list(th)   (void)(th)
#define ubf_select   0
#define TT_DEBUG   0
#define WRITE_CONST(fd, str)   (void)(write((fd),(str),sizeof(str)-1)<0)
#define TIME_QUANTUM_USEC   (100 * 1000)
#define PER_NANO   1000000000

Typedefs

typedef unsigned long unsigned_time_t

Enumerations

enum  { RUBY_STACK_SPACE_LIMIT = 1024 * 1024, RUBY_STACK_SPACE_RATIO = 5 }

Functions

static void native_mutex_lock (pthread_mutex_t *lock)
static void native_mutex_unlock (pthread_mutex_t *lock)
static int native_mutex_trylock (pthread_mutex_t *lock)
static void native_mutex_initialize (pthread_mutex_t *lock)
static void native_mutex_destroy (pthread_mutex_t *lock)
static void native_cond_signal (rb_thread_cond_t *cond)
static void native_cond_broadcast (rb_thread_cond_t *cond)
static void native_cond_wait (rb_thread_cond_t *cond, pthread_mutex_t *mutex)
static void native_cond_initialize (rb_thread_cond_t *cond, int flags)
static void native_cond_destroy (rb_thread_cond_t *cond)
static void rb_thread_wakeup_timer_thread_low (void)
static void gvl_acquire_common (rb_vm_t *vm)
static void gvl_acquire (rb_vm_t *vm, rb_thread_t *th)
static void gvl_release_common (rb_vm_t *vm)
static void gvl_release (rb_vm_t *vm)
static void gvl_yield (rb_vm_t *vm, rb_thread_t *th)
static void gvl_init (rb_vm_t *vm)
static void gvl_destroy (rb_vm_t *vm)
static void gvl_atfork (rb_vm_t *vm)
static void mutex_debug (const char *msg, pthread_mutex_t *lock)
static int native_cond_timedwait (rb_thread_cond_t *cond, pthread_mutex_t *mutex, struct timespec *ts)
static struct timespec native_cond_timeout (rb_thread_cond_t *cond, struct timespec timeout_rel)
static void null_func (int i)
static rb_thread_truby_thread_from_native (void)
static int ruby_thread_set_native (rb_thread_t *th)
static void native_thread_init (rb_thread_t *th)
void Init_native_thread (void)
static void native_thread_destroy (rb_thread_t *th)
static size_t space_size (size_t stack_size)
void ruby_init_stack (volatile VALUE *addr)
static int native_thread_init_stack (rb_thread_t *th)
static void * thread_start_func_1 (void *th_ptr)
static int use_cached_thread (rb_thread_t *th)
static int native_thread_create (rb_thread_t *th)
static void native_thread_join (pthread_t th)
static int native_fd_select (int n, rb_fdset_t *readfds, rb_fdset_t *writefds, rb_fdset_t *exceptfds, struct timeval *timeout, rb_thread_t *th)
static void ubf_pthread_cond_signal (void *ptr)
static void native_sleep (rb_thread_t *th, struct timeval *timeout_tv)
static void ping_signal_thread_list (void)
static int check_signal_thread_list (void)
void rb_thread_wakeup_timer_thread (void)
static void timer_thread_sleep (rb_global_vm_lock_t *unused)
static void * thread_timer (void *p)
static void rb_thread_create_timer_thread (void)
static int native_stop_timer_thread (int close_anyway)
static void native_reset_timer_thread (void)
int rb_reserved_fd_p (int fd)

Variables

static pthread_t timer_thread_id
static pthread_key_t ruby_native_thread_key
struct {
   rb_thread_id_t   id
   size_t   stack_maxsize
   VALUE *   stack_start
native_main_thread
static pthread_mutex_t timer_thread_lock
static rb_thread_cond_t timer_thread_cond

Define Documentation

#define add_signal_thread_list ( th   )     (void)(th)

Definition at line 1153 of file thread_pthread.c.

#define ARRAY_SIZE (  )     (sizeof(x) / sizeof((x)[0]))

Definition at line 71 of file thread_pthread.c.

#define CHECK_ERR ( expr   )     {int err = (expr); if (err) {rb_bug_errno(#expr, err);}}

Definition at line 710 of file thread_pthread.c.

Referenced by native_thread_create(), and native_thread_init_stack().

#define MAINSTACKADDR_AVAILABLE   0

Definition at line 520 of file thread_pthread.c.

#define native_cleanup_pop   pthread_cleanup_pop

Definition at line 427 of file thread_pthread.c.

#define native_cleanup_push   pthread_cleanup_push

Definition at line 426 of file thread_pthread.c.

#define NATIVE_MUTEX_LOCK_DEBUG   0

Definition at line 191 of file thread_pthread.c.

Referenced by mutex_debug().

 
#define native_thread_yield (  )     ((void)0)

Definition at line 431 of file thread_pthread.c.

Referenced by gvl_yield().

#define PER_NANO   1000000000

Definition at line 1353 of file thread_pthread.c.

#define RB_CONDATTR_CLOCK_MONOTONIC   1
#define remove_signal_thread_list ( th   )     (void)(th)

Definition at line 1154 of file thread_pthread.c.

Referenced by blocking_region_end().

#define TIME_QUANTUM_USEC   (100 * 1000)
#define TIMET_MAX   (~(time_t)0 <= 0 ? (time_t)((~(unsigned_time_t)0) >> 1) : (time_t)(~(unsigned_time_t)0))

Definition at line 379 of file thread_pthread.c.

#define TT_DEBUG   0
#define ubf_select   0
#define USE_MONOTONIC_COND   0

Definition at line 60 of file thread_pthread.c.

#define USE_NATIVE_THREAD_INIT   1

Definition at line 744 of file thread_pthread.c.

#define USE_SLEEPY_TIMER_THREAD   0

Definition at line 67 of file thread_pthread.c.

#define USE_THREAD_CACHE   0

Definition at line 495 of file thread_pthread.c.

#define WRITE_CONST ( fd,
str   )     (void)(write((fd),(str),sizeof(str)-1)<0)

Definition at line 1161 of file thread_pthread.c.


Typedef Documentation

typedef unsigned long unsigned_time_t

Definition at line 370 of file thread_pthread.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
RUBY_STACK_SPACE_LIMIT 
RUBY_STACK_SPACE_RATIO 

Definition at line 606 of file thread_pthread.c.


Function Documentation

static int check_signal_thread_list ( void   )  [static]

Definition at line 1157 of file thread_pthread.c.

static void gvl_acquire ( rb_vm_t vm,
rb_thread_t th 
) [static]
static void gvl_acquire_common ( rb_vm_t vm  )  [static]
static void gvl_atfork ( rb_vm_t vm  )  [static]

Definition at line 185 of file thread_pthread.c.

References GET_THREAD(), gvl_acquire(), and gvl_init().

Referenced by rb_thread_atfork_internal().

static void gvl_destroy ( rb_vm_t vm  )  [static]
static void gvl_init ( rb_vm_t vm  )  [static]
static void gvl_release ( rb_vm_t vm  )  [static]
static void gvl_release_common ( rb_vm_t vm  )  [static]
static void gvl_yield ( rb_vm_t vm,
rb_thread_t th 
) [static]
void Init_native_thread ( void   ) 
static void mutex_debug ( const char *  msg,
pthread_mutex_t *  lock 
) [static]
static void native_cond_broadcast ( rb_thread_cond_t cond  )  [static]

Definition at line 327 of file thread_pthread.c.

References rb_thread_cond_struct::cond, and rb_bug_errno().

Referenced by gvl_yield(), and lock_interrupt().

static void native_cond_destroy ( rb_thread_cond_t cond  )  [static]
static void native_cond_initialize ( rb_thread_cond_t cond,
int  flags 
) [static]
static void native_cond_signal ( rb_thread_cond_t cond  )  [static]
static int native_cond_timedwait ( rb_thread_cond_t cond,
pthread_mutex_t *  mutex,
struct timespec *  ts 
) [static]

Definition at line 348 of file thread_pthread.c.

References rb_thread_cond_struct::cond, ETIMEDOUT, and rb_bug_errno().

Referenced by lock_func(), native_sleep(), and timer_thread_sleep().

static struct timespec native_cond_timeout ( rb_thread_cond_t cond,
struct timespec  timeout_rel 
) [static, read]
static void native_cond_wait ( rb_thread_cond_t cond,
pthread_mutex_t *  mutex 
) [static]
static int native_fd_select ( int  n,
rb_fdset_t *  readfds,
rb_fdset_t *  writefds,
rb_fdset_t *  exceptfds,
struct timeval timeout,
rb_thread_t th 
) [static]

Definition at line 961 of file thread_pthread.c.

References rb_fd_select.

Referenced by do_select().

static void native_mutex_destroy ( pthread_mutex_t *  lock  )  [static]
static void native_mutex_initialize ( pthread_mutex_t *  lock  )  [static]
static void native_mutex_lock ( pthread_mutex_t *  lock  )  [static]
static int native_mutex_trylock ( pthread_mutex_t *  lock  )  [inline, static]

Definition at line 227 of file thread_pthread.c.

References mutex_debug(), and rb_bug_errno().

Referenced by Init_Thread().

static void native_mutex_unlock ( pthread_mutex_t *  lock  )  [static]
static void native_reset_timer_thread ( void   )  [static]

Definition at line 1490 of file thread_pthread.c.

References TT_DEBUG.

Referenced by rb_thread_reset_timer_thread(), and rb_thread_stop_timer_thread().

static void native_sleep ( rb_thread_t th,
struct timeval timeout_tv 
) [static]
static int native_stop_timer_thread ( int  close_anyway  )  [static]
static int native_thread_create ( rb_thread_t th  )  [static]
static void native_thread_destroy ( rb_thread_t th  )  [static]
static void native_thread_init ( rb_thread_t th  )  [static]
static int native_thread_init_stack ( rb_thread_t th  )  [static]
static void native_thread_join ( pthread_t  th  )  [static]

Definition at line 921 of file thread_pthread.c.

References err, rb_eThreadError, and rb_raise().

Referenced by native_stop_timer_thread().

static void null_func ( int  i  )  [static]

Definition at line 446 of file thread_pthread.c.

Referenced by Init_native_thread().

static void ping_signal_thread_list ( void   )  [static]

Definition at line 1156 of file thread_pthread.c.

Referenced by thread_timer().

int rb_reserved_fd_p ( int  fd  ) 

Definition at line 1531 of file thread_pthread.c.

Referenced by rb_io_initialize().

static void rb_thread_create_timer_thread ( void   )  [static]
void rb_thread_wakeup_timer_thread ( void   ) 

Definition at line 1354 of file thread_pthread.c.

Referenced by native_stop_timer_thread(), and sighandler().

static void rb_thread_wakeup_timer_thread_low ( void   )  [static]

Definition at line 1355 of file thread_pthread.c.

Referenced by gvl_acquire_common().

void ruby_init_stack ( volatile VALUE *  addr  ) 
static rb_thread_t* ruby_thread_from_native ( void   )  [static]
static int ruby_thread_set_native ( rb_thread_t th  )  [static]

Definition at line 458 of file thread_pthread.c.

References ruby_native_thread_key.

Referenced by native_thread_init(), and thread_start_func_2().

static size_t space_size ( size_t  stack_size  )  [static]
static void* thread_start_func_1 ( void *  th_ptr  )  [static]
static void* thread_timer ( void *  p  )  [static]
static void timer_thread_sleep ( rb_global_vm_lock_t unused  )  [inline, static]

Definition at line 1361 of file thread_pthread.c.

References native_cond_timedwait(), native_cond_timeout(), and TIME_QUANTUM_USEC.

Referenced by thread_timer().

static void ubf_pthread_cond_signal ( void *  ptr  )  [static]

Definition at line 967 of file thread_pthread.c.

References native_cond_signal(), and thread_debug.

Referenced by native_sleep().

static int use_cached_thread ( rb_thread_t th  )  [static]

Variable Documentation

Definition at line 594 of file thread_pthread.c.

struct { ... } native_main_thread [static]
pthread_key_t ruby_native_thread_key [static]
size_t stack_maxsize

Definition at line 595 of file thread_pthread.c.

VALUE* stack_start

Definition at line 1358 of file thread_pthread.c.

pthread_t timer_thread_id [static]
pthread_mutex_t timer_thread_lock [static]

Definition at line 1357 of file thread_pthread.c.


Generated on 18 May 2020 for Ruby by  doxygen 1.6.1