@@ -8,17 +8,14 @@ author: loongs-zhang
88
99## Why hook?
1010
11- After a ` Coroutine::resume_with ` , a coroutine may occupy the scheduling thread for a long time, thereby slowing down
12- other coroutines scheduled by that scheduling thread. To solve this problem, we introduce hook, which automatically
13- suspends coroutines entering syscall and allow other coroutines to execute.
11+ After a ` Coroutine::resume_with ` , a coroutine may occupy the scheduling thread for a long time (e.g. getting stuck in
12+ heavy computing or syscall), thereby slowing down other coroutines scheduled by that scheduling thread. To solve the
13+ problem of getting stuck in syscall, we introduce hook, which automatically suspends coroutines that enter syscall and
14+ allow other coroutines to execute.
1415
15- The coroutine occupies scheduling threads for a long time in two scenarios: getting stuck in heavy computing or syscall.
16- The following only solves the problem of getting stuck in syscall.
17-
18- Another problem is that ` signals can interrupt the running syscall ` , and the ` preemptive ` feature mechanism sends a
19- large
20- number of signals. In addition, most user code does not handle signals, if they directly use ` open-routine-core ` and
21- enabling preemptive will lead to ` catastrophic consequences ` .
16+ This brings a new problem, the ` preemptive ` feature will send a large number of signals `which can interrupt the running
17+ syscall` . In addition, most user code does not handle signals, if they directly use ` open-routine-core` and enabling the
18+ preemptive feature will lead to ` catastrophic consequences ` .
2219
2320## What is hook?
2421
@@ -40,8 +37,8 @@ fn test_hook() {
4037}
4138```
4239
43- If we don't hook, this test would almost never end due to ` std::thread::sleep(Duration::MAX) ` , but with hook, we
44- redirect the ` nanosleep ` syscall
40+ If we don't hook, because ` std::thread::sleep(Duration::MAX) ` , this test almost never ends, but with hook, we redirect
41+ the ` nanosleep ` syscall
4542to [ our custom code] ( https://github.com/loongs-zhang/link-example/blob/master/dep/src/lib.rs ) `without change the test
4643code`, and then the test
4744will [ end soon] ( https://github.com/loongs-zhang/link-example/actions/runs/12862762378/job/35858206179 ) .
0 commit comments