gpt4 book ai didi

linux - Linux内核-CGROUPS的CPU子系统与CPU调度程序有何不同?

转载 作者:行者123 更新时间:2023-12-02 21:02:17 26 4
gpt4 key购买 nike

Linux内核代码here提供了 CPU调度程序,它具有用于调度进程(包括docker容器进程)的多种调度算法。

控制组是一个内核构造,它允许一组进程限制对主机系统物理资源的访问和使用。

控制组最初于2007年在Linux内核中实现。

在Linux内核4.5中,该版本1的实现被版本2的实现所替代。版本2修复了与版本1实现相关的一些限制。

Linux内核中六个CGROUP子系统中的两个子系统是 cpu子系统 cpuset子系统

cpu子系统控制通过调度程序对系统CPU的访问

cpuset子系统将属于CGROUPS的进程固定到特定的CPU内核或内存节点。

CPU调度程序与(CGROUPS的) cpu子系统有何不同?与默认 namespace 与多个 namespace 有关?

最佳答案

如果没有过多的简化,很难给出一个“简短的答案”。一个人可以写一本有关“CPU调度”的书,另一本书可以写一本“Linux控制组”的书。

而不是“CPU调度程序与... Cgroup有什么不同?”,一个更好的问题可能是“Linux Cgroup与Linux进程有何不同?”。

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/resource_management_guide/ch01

How Control Groups Are Organized

Cgroups are organized hierarchically, like processes, and child cgroups inherit some of the attributes of their parents. However, there are differences between the two models.

The Linux Process Model

All processes on a Linux system are child processes of a common parent: the init process, which is executed by the kernel at boot time and starts other processes (which may in turn start child processes of their own). Because all processes descend from a single parent, the Linux process model is a single hierarchy, or tree.

Additionally, every Linux process except init inherits the environment (such as the PATH variable)[1] and certain other attributes (such as open file descriptors) of its parent process.

The Cgroup Model

Cgroups are similar to processes in that:

  • they are hierarchical, and
  • child cgroups inherit certain attributes from their parent cgroup.

The fundamental difference is that many different hierarchies of cgroups can exist simultaneously on a system. If the Linux process model is a single tree of processes, then the cgroup model is one or more separate, unconnected trees of tasks (i.e. processes).

Multiple separate hierarchies of cgroups are necessary because each hierarchy is attached to one or more subsystems. A subsystem[2] represents a single resource, such as CPU time or memory.



回到您最初的问题:
  • Linux CPU调度程序为进程分配时间。
  • CONFIG_CGROUP_SCHED组调度程序扩展允许任务
    分组并在这些组之间公平地分配CPU时间。

  • 在这里查看更多信息:
  • http://man7.org/linux/man-pages/man7/cgroups.7.html
  • https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt
  • https://www.kernel.org/doc/Documentation/cgroup-v2.txt
  • https://opensource.com/article/19/2/fair-scheduling-linux
  • 关于linux - Linux内核-CGROUPS的CPU子系统与CPU调度程序有何不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60046244/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com