DragonOS icon indicating copy to clipboard operation
DragonOS copied to clipboard

[BUG REPORT] nanosleep在多线程中会被提前唤醒结束

Open sun5etop opened this issue 1 year ago • 3 comments

描述错误

  • 在rust程序中,thread::sleep(millis)函数会使当前进程睡眠millis毫秒,但当收到当前线程结束信号时,即使睡眠时间没有达到millis毫秒也会强制提前结束睡眠。
  • 逻辑有误的地方在DragonOS/kernel/src/time/sleep.rs中的nanosleep函数, ProcessManager::mark_sleep(true).ok(); 使得当前睡眠提前打断结束。

请填写您的电脑的信息:

操作系统及版本:Ubuntu 22.04 DragonOS版本:c719ddc DADK版本:0.1.10 Rust版本:1.68

重现步骤

  • 例如以下程序: 1713288809116

期望行为 让nanosleep能正确处理当前进程结束传来的信息,完成睡眠时间。

sun5etop avatar Apr 16 '24 17:04 sun5etop

跟这个 https://github.com/DragonOS-Community/DragonOS/issues/684 有点类似,都是信号处理结束后未能再次重启调用。

fslongjin avatar Apr 16 '24 17:04 fslongjin

r? @Chiichen 麻烦看看这个

fslongjin avatar Apr 17 '24 01:04 fslongjin

https://github.com/DragonOS-Community/DragonOS/issues/684#issuecomment-2060448442 感觉是上下文的保存和恢复有点问题

chiichen avatar Apr 17 '24 06:04 chiichen