🌐 AI搜索 & 代理 主页
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion thread_pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -3001,7 +3001,7 @@ timer_thread_deq_wakeup(rb_vm_t *vm, rb_hrtime_t now, uint32_t *event_serial)
static void
timer_thread_wakeup_thread_locked(struct rb_thread_sched *sched, rb_thread_t *th, uint32_t event_serial)
{
if (sched->running != th && th->event_serial == event_serial) {
if (sched->running != th && th->sched.event_serial == event_serial) {
thread_sched_to_ready_common(sched, th, true, false);
}
}
Expand Down
3 changes: 2 additions & 1 deletion thread_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct rb_thread_sched_waiting {
struct ccan_list_node node;
};

// per-Thead scheduler helper data
// per-Thread scheduler helper data
struct rb_thread_sched_item {
struct {
struct ccan_list_node ubf;
Expand All @@ -70,6 +70,7 @@ struct rb_thread_sched_item {
} node;

struct rb_thread_sched_waiting waiting_reason;
uint32_t event_serial;

bool finished;
bool malloc_stack;
Expand Down
6 changes: 3 additions & 3 deletions thread_pthread_mn.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ thread_sched_wait_events(struct rb_thread_sched *sched, rb_thread_t *th, int fd,

volatile bool timedout = false, need_cancel = false;

uint32_t event_serial = ++th->event_serial; // overflow is okay
uint32_t event_serial = ++th->sched.event_serial; // overflow is okay

if (ubf_set(th, ubf_event_waiting, (void *)th)) {
return false;
Expand All @@ -81,11 +81,11 @@ thread_sched_wait_events(struct rb_thread_sched *sched, rb_thread_t *th, int fd,
RB_INTERNAL_THREAD_HOOK(RUBY_INTERNAL_THREAD_EVENT_SUSPENDED, th);

if (th->sched.waiting_reason.flags == thread_sched_waiting_none) {
th->event_serial++;
th->sched.event_serial++;
// timer thread has dequeued us already, but it won't try to wake us because we bumped our serial
}
else if (RUBY_VM_INTERRUPTED(th->ec)) {
th->event_serial++; // make sure timer thread doesn't try to wake us
th->sched.event_serial++; // make sure timer thread doesn't try to wake us
need_cancel = true;
}
else {
Expand Down
1 change: 0 additions & 1 deletion vm_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,6 @@ typedef struct rb_thread_struct {
struct rb_thread_sched_item sched;
bool mn_schedulable;
rb_atomic_t serial; // only for RUBY_DEBUG_LOG()
uint32_t event_serial;

VALUE last_status; /* $? */

Expand Down
Loading