Skip to content

Commit 601ea78

Browse files
authored
less syscall (#441)
2 parents 697ed2d + 71135ff commit 601ea78

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

core/src/monitor.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ impl Monitor {
7474
#[cfg(unix)]
7575
extern "C" fn sigurg_handler(_: libc::c_int) {
7676
if let Ok(mut set) = SigSet::thread_get_mask() {
77-
//删除对SIGURG信号的屏蔽,使信号处理函数即使在处理中,也可以再次进入信号处理函数
78-
set.remove(Signal::SIGURG);
79-
set.thread_set_mask()
80-
.expect("Failed to remove SIGURG signal mask!");
81-
//不抢占处于Syscall状态的协程。
77+
//只抢占处于Running状态的协程。
8278
//MonitorListener的设计理念是不对Syscall状态的协程发送信号。
8379
//但由于NOTIFY_NODE移除和monitor线程遍历之间存在竞态条件,
8480
//SIGURG可能在协程刚进入Syscall状态时到达。
@@ -92,10 +88,14 @@ impl Monitor {
9288
// coroutine lands in the syscall map with no io_uring/epoll/timer
9389
// registration to wake it, causing a deadlock.
9490
if let Some(co) = SchedulableCoroutine::current() {
95-
if matches!(co.state(), CoroutineState::Syscall((), _, _)) {
91+
if !matches!(co.state(), CoroutineState::Running) {
9692
return;
9793
}
9894
}
95+
//删除对SIGURG信号的屏蔽,使信号处理函数即使在处理中,也可以再次进入信号处理函数
96+
set.remove(Signal::SIGURG);
97+
set.thread_set_mask()
98+
.expect("Failed to remove SIGURG signal mask!");
9999
if let Some(suspender) = SchedulableSuspender::current() {
100100
suspender.suspend();
101101
}
@@ -541,7 +541,7 @@ extern "C" fn do_preempt() {
541541
// coroutine never yielded (no hooked syscalls) — it is truly CPU-bound.
542542
// Force immediate suspension.
543543
flag.set(false);
544-
//不抢占处于Syscall状态的协程
544+
//只抢占处于Running状态的协程
545545
//MonitorListener的设计理念是不对Syscall状态的协程发送信号。
546546
//但由于NOTIFY_NODE移除和monitor线程遍历之间存在竞态条件,
547547
//SIGURG可能在协程刚进入Syscall状态时到达。
@@ -555,7 +555,7 @@ extern "C" fn do_preempt() {
555555
// coroutine lands in the syscall map with no io_uring/epoll/timer
556556
// registration to wake it, causing a deadlock.
557557
if let Some(co) = SchedulableCoroutine::current() {
558-
if matches!(co.state(), CoroutineState::Syscall((), _, _)) {
558+
if !matches!(co.state(), CoroutineState::Running) {
559559
return;
560560
}
561561
}

0 commit comments

Comments
 (0)