Skip to content
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

feat(sched): add sched_yield #766

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

zwb0x00
Copy link
Contributor

@zwb0x00 zwb0x00 commented Apr 24, 2024

issue: #756

@dragonosbot
Copy link

@zwb0x00: no appropriate reviewer found, use r? to override

@dragonosbot dragonosbot added the S-等待审查 Status: 等待assignee以及相关方的审查。 label Apr 24, 2024
@github-actions github-actions bot added the enhancement New feature or request label Apr 24, 2024
@fslongjin fslongjin requested a review from GnoCiYeH April 24, 2024 15:51
@@ -1007,6 +1008,31 @@ impl Syscall {
Self::fchmodat(dirfd, pathname, mode)
}

SYS_SCHED_YIELD => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉将这个封装成一个函数会比较好一点

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

每个子系统的系统调用,一般是写到对应模块的syscall.rs里面去哈哈,比如sched/syscall.rs

Copy link
Contributor Author

@zwb0x00 zwb0x00 Apr 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,了解了

@fslongjin
Copy link
Member

@dragonosbot author

@dragonosbot dragonosbot added S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。 and removed S-等待审查 Status: 等待assignee以及相关方的审查。 labels Apr 25, 2024
@zwb0x00
Copy link
Contributor Author

zwb0x00 commented Apr 25, 2024

@dragonosbot ready

@fslongjin fslongjin requested a review from GnoCiYeH April 25, 2024 16:27
@fslongjin fslongjin added S-等待审查 Status: 等待assignee以及相关方的审查。 and removed S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。 labels Apr 26, 2024

CompletelyFairScheduler::yield_task(rq);

pcb.preempt_disable();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的preempt_disablepreempt_enable似乎没有什么必要?,这里已经禁用中断,是不会被时钟中断调度走的,所以我感觉可以不需要这个两个调用。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里完全参考linux实现,应该是保证在一些特殊情况下也不会被抢占,保证drop(guard)和drop(irq_guard)成功执行。可以暂时先保持原状。


pcb.preempt_enable(); // sched_preempt_enable_no_resched();

schedule(SchedMode::SM_NONE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里我看Linux也是这样写的,但是我有个问题是,根据man手册:
image

调用进程会被放置至队尾,但是目前我们的调度系统SM_NONE是不会将其放入队尾的。应该是__schedule函数某个地方有问题。。你有兴趣看一下吗<

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以的~

@GnoCiYeH
Copy link
Member

@dragonosbot author

@dragonosbot dragonosbot added S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。 and removed S-等待审查 Status: 等待assignee以及相关方的审查。 labels Apr 26, 2024
@GnoCiYeH GnoCiYeH merged commit 173c456 into DragonOS-Community:master Apr 26, 2024
7 checks passed
BrahmaMantra pushed a commit to BrahmaMantra/DragonOS that referenced this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request S-等待作者修改 Status: 这正在等待作者的一些操作(例如代码更改或更多信息)。
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants