summaryrefslogtreecommitdiff
path: root/thread_pthread.h
diff options
context:
space:
mode:
Diffstat (limited to 'thread_pthread.h')
-rw-r--r--thread_pthread.h67
1 files changed, 39 insertions, 28 deletions
diff --git a/thread_pthread.h b/thread_pthread.h
index 20c4b9f9a8..992e9fb080 100644
--- a/thread_pthread.h
+++ b/thread_pthread.h
@@ -17,7 +17,38 @@
#define RB_NATIVETHREAD_LOCK_INIT PTHREAD_MUTEX_INITIALIZER
#define RB_NATIVETHREAD_COND_INIT PTHREAD_COND_INITIALIZER
-// per-Thead scheduler helper data
+// TLS can not be accessed across .so on arm64 and perhaps ppc64le too.
+#if defined(__arm64__) || defined(__aarch64__) || defined(__powerpc64__)
+# define RB_THREAD_CURRENT_EC_NOINLINE
+#endif
+
+// this data should be protected by timer_th.waiting_lock
+struct rb_thread_sched_waiting {
+ enum thread_sched_waiting_flag {
+ thread_sched_waiting_none = 0x00,
+ thread_sched_waiting_timeout = 0x01,
+ thread_sched_waiting_io_read = 0x02,
+ thread_sched_waiting_io_write = 0x08,
+ thread_sched_waiting_io_force = 0x40, // ignore readable
+ } flags;
+
+ struct {
+ // should be compat with hrtime.h
+#ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
+ int128_t timeout;
+#else
+ uint64_t timeout;
+#endif
+ uint32_t event_serial;
+ int fd; // -1 for timeout only
+ int result;
+ } data;
+
+ // connected to timer_th.waiting
+ struct ccan_list_node node;
+};
+
+// per-Thread scheduler helper data
struct rb_thread_sched_item {
struct {
struct ccan_list_node ubf;
@@ -38,30 +69,8 @@ struct rb_thread_sched_item {
struct ccan_list_node zombie_threads;
} node;
- // this data should be protected by timer_th.waiting_lock
- struct {
- enum thread_sched_waiting_flag {
- thread_sched_waiting_none = 0x00,
- thread_sched_waiting_timeout = 0x01,
- thread_sched_waiting_io_read = 0x02,
- thread_sched_waiting_io_write = 0x08,
- thread_sched_waiting_io_force = 0x40, // ignore readable
- } flags;
-
- struct {
- // should be compat with hrtime.h
-#ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
- int128_t timeout;
-#else
- uint64_t timeout;
-#endif
- int fd; // -1 for timeout only
- int result;
- } data;
-
- // connected to timer_th.waiting
- struct ccan_list_node node;
- } waiting_reason;
+ struct rb_thread_sched_waiting waiting_reason;
+ uint32_t event_serial;
bool finished;
bool malloc_stack;
@@ -130,10 +139,8 @@ struct rb_thread_sched {
#ifdef RB_THREAD_LOCAL_SPECIFIER
NOINLINE(void rb_current_ec_set(struct rb_execution_context_struct *));
- NOINLINE(struct rb_execution_context_struct *rb_current_ec_noinline(void));
- # ifdef __APPLE__
- // on Darwin, TLS can not be accessed across .so
+ # ifdef RB_THREAD_CURRENT_EC_NOINLINE
NOINLINE(struct rb_execution_context_struct *rb_current_ec(void));
# else
RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec;
@@ -163,4 +170,8 @@ native_tls_set(native_tls_key_t key, void *ptr)
RUBY_EXTERN native_tls_key_t ruby_current_ec_key;
#endif
+struct rb_ractor_struct;
+void rb_ractor_sched_wait(struct rb_execution_context_struct *ec, struct rb_ractor_struct *cr, rb_unblock_function_t *ubf, void *ptr);
+void rb_ractor_sched_wakeup(struct rb_ractor_struct *r, struct rb_thread_struct *th);
+
#endif /* RUBY_THREAD_PTHREAD_H */