aboutsummaryrefslogtreecommitdiffstats
path: root/thread_pthread.h
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2022-04-17 03:40:23 +0900
committerKoichi Sasada <ko1@atdot.net>2022-04-22 07:54:09 +0900
commit1c4fc0241d125879e1e5169f267f26637772f3a7 (patch)
treed23704a9fc31fe8bfb29835ce0bdae3dc278b513 /thread_pthread.h
parentcb02324c4e5c7aae0add0a5c4e5adbf637d9acb0 (diff)
downloadruby-1c4fc0241d125879e1e5169f267f26637772f3a7.tar.gz
rename thread internal naming
Now GVL is not process *Global* so this patch try to use another words. * `rb_global_vm_lock_t` -> `struct rb_thread_sched` * `gvl->owner` -> `sched->running` * `gvl->waitq` -> `sched->readyq` * `rb_gvl_init` -> `rb_thread_sched_init` * `gvl_destroy` -> `rb_thread_sched_destroy` * `gvl_acquire` -> `thread_sched_to_running` # waiting -> ready -> running * `gvl_release` -> `thread_sched_to_waiting` # running -> waiting * `gvl_yield` -> `thread_sched_yield` * `GVL_UNLOCK_BEGIN` -> `THREAD_BLOCKING_BEGIN` * `GVL_UNLOCK_END` -> `THREAD_BLOCKING_END` * removed * `rb_ractor_gvl` * `rb_vm_gvl_destroy` (not used) There are GVL functions such as `rb_thread_call_without_gvl()` yet but I don't have good name to replace them. Maybe GVL stands for "Greate Valuable Lock" or something like that.
Diffstat (limited to 'thread_pthread.h')
-rw-r--r--thread_pthread.h23
1 files changed, 12 insertions, 11 deletions
diff --git a/thread_pthread.h b/thread_pthread.h
index 38a006627a..f65916fea9 100644
--- a/thread_pthread.h
+++ b/thread_pthread.h
@@ -20,7 +20,7 @@
typedef struct native_thread_data_struct {
union {
struct ccan_list_node ubf;
- struct ccan_list_node gvl;
+ struct ccan_list_node readyq; // protected by sched->lock
} node;
#if defined(__GLIBC__) || defined(__FreeBSD__)
union
@@ -33,7 +33,7 @@ typedef struct native_thread_data_struct {
#endif
{
rb_nativethread_cond_t intr; /* th->interrupt_lock */
- rb_nativethread_cond_t gvlq; /* vm->gvl.lock */
+ rb_nativethread_cond_t readyq; /* use sched->lock */
} cond;
} native_thread_data_t;
@@ -42,15 +42,17 @@ typedef struct native_thread_data_struct {
#undef leave
#undef finally
-typedef struct rb_global_vm_lock_struct {
+// per-Ractor
+struct rb_thread_sched {
/* fast path */
- const struct rb_thread_struct *owner;
- rb_nativethread_lock_t lock; /* AKA vm->gvl.lock */
+
+ const struct rb_thread_struct *running; // running thread or NULL
+ rb_nativethread_lock_t lock;
/*
- * slow path, protected by vm->gvl.lock
- * - @waitq - FIFO queue of threads waiting for GVL
- * - @timer - it handles timeslices for @owner. It is any one thread
+ * slow path, protected by ractor->thread_sched->lock
+ * - @readyq - FIFO queue of threads waiting for running
+ * - @timer - it handles timeslices for @current. It is any one thread
* in @waitq, there is no @timer if @waitq is empty, but always
* a @timer if @waitq has entries
* - @timer_err tracks timeslice limit, the timeslice only resets
@@ -58,7 +60,7 @@ typedef struct rb_global_vm_lock_struct {
* switching between contended/uncontended GVL won't reset the
* timer.
*/
- struct ccan_list_head waitq; /* <=> native_thread_data_t.node.ubf */
+ struct ccan_list_head readyq;
const struct rb_thread_struct *timer;
int timer_err;
@@ -67,8 +69,7 @@ typedef struct rb_global_vm_lock_struct {
rb_nativethread_cond_t switch_wait_cond;
int need_yield;
int wait_yield;
-} rb_global_vm_lock_t;
-
+};
#if __STDC_VERSION__ >= 201112
#define RB_THREAD_LOCAL_SPECIFIER _Thread_local