繁体   English   中英

在fork之后的exec系统调用中调度策略

[英]Scheduling Policy in an exec system call after a fork

假设我有一个子进程,我的调度策略我已经设置为SCHED_BATCH ,使用C库的函数sched_setscheduler ,现在,这个子进程使用execvp系统调用创建一个外部进程。

创建的新进程的调度程序是否与前一个子进程的调度程序相同,即通过execvp系统调用继承的调度策略是什么? 我已经阅读了手册页,其中说明FIFORR策略是继承的,但是正常的策略如SCHED_BATCHSCHED_IDLESCHED_OTHER呢?

是否有任何exec系列的功能支持所有调度策略的继承?

首先, exec系列调用不执行它自己的图像,而是执行它加载的二进制文件。 按照man exec

The exec() family of functions replaces the current process image with a new process image.

因此,它将表现出如何准备安排特定的可执行映像。

当一个进程被标记为SCHED_BATCH ,它们将根据它们的好值进行调度,就像SCHED_OTHER一样。 由于批处理任务不需要用户交互,因此调度程序将任务视为CPU密集型。 根据man sched_setschedparam引用SCHED_BATCH: Scheduling batch process -

This policy is similar to SCHED_OTHER in that it schedules the process according to its dynamic priority (based on the nice value).The difference is that this policy will cause the scheduler to always assume that the process is CPU-intensive. Consequently, the scheduler will apply a small scheduling penalty with respect to wakeup behaviour, so that this process is mildly disfavored in scheduling decisions.

因此,如果您将进程的调度策略更改为SCHED_BATCH ,则它将像几乎任何其他正常进程(SCHED_OTHER,默认调度策略)一样进行调度。 如果要回SCHED_RESET_ON_FORK完全默认行为,则必须使用SCHED_RESET_ON_FORK标志与调度策略进行OR运算。 如果指定该标志,则任何新创建的进程都将回退到默认调度策略,而不是复制父进程。

希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM