-
-
Notifications
You must be signed in to change notification settings - Fork 158
sys_alarm系统调用初步实现 #698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys_alarm系统调用初步实现 #698
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
提交之前要先make fmt
@@ -693,6 +709,7 @@ impl ProcessControlBlock { | |||
children: RwLock::new(Vec::new()), | |||
wait_queue: WaitQueue::default(), | |||
thread: RwLock::new(ThreadInfo::new()), | |||
alarm_timer: Arc::new(Mutex::new(None)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么不是Option<Arc<AlarmTimer>>
?
目前这种写法的封装性不好。这些处理是否可变的操作,应当封装到里面去。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉会不会存在多线程同时访问alarm产生数据竞争,Arc<Mutex<>>能支持内部可变
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要把Mutex封装到AlarmTimer
里面去。而不是暴露出来。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
了解🫡
} | ||
|
||
impl AlarmTimer { | ||
pub fn new(timer_func: Box<dyn TimerFunction>, expire_time: u64) -> Mutex<Option<Self>>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个expire的是jiffies吗?如果是的话把变量名改为expired_jifffies
@@ -0,0 +1,14 @@ | |||
# DragonOS Rust-Application Template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改名称
|
||
//test1: alarm系统调用能否正常运行 | ||
unsafe { | ||
syscall(37,5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要直接写系统调用号。
原因: #682 (comment)
okok马上修改 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我在想这些持续时间都用Duration表示是不是方便一点,不用搞这些s, ms, ns的转换了。后面可以考虑移植一下 std 里的 instatnt 和duaration,结合起来就方便很多了,这种东西还是挺容易出错的
//这里的second是以jiddies为单位 | ||
//Todo:秒转换成jiddies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
打错了?应该是jiffies
} | ||
|
||
//初始化目标进程的alarm定时器 | ||
pub fn alarm_timer_init(pid: Pid, time_out: u64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同样的,这里如果是jiffies的话要体现出来,如果不是的话就写time_out_sec
与主线代码有冲突,要解决一下。还有,就是开发不要直接用自己仓库的master开发,要新建一个分支 |
确实直接用秒在计算剩余秒数时可能会有误差 |
实现思想及过程
测试程序