cgroups freeze和Linux命令”Kill – STOP pid”在golang中有什么区别?

huangapple go评论97阅读模式
英文:

What is the difference between cgroups freeze and linux command "Kill - STOP pid" in golang?

问题

我使用这个cgroups包。

我对type Cgroup中的两个接口感兴趣。一个是Freeze() error,另一个是Thaw() error。它们的描述如下:

    ...
	// Freeze冻结或暂停cgroup中的所有进程
	Freeze() error
	// Thaw解冻或恢复cgroup中的所有进程
	Thaw() error
    ...

还有两个Linux命令可以暂停和恢复进程,分别是kill -STOP pidkill -CONT pid

我想知道如果一个cgroup中只有一个进程,使用这两种方式来暂停和恢复进程是否有任何区别?谢谢。

英文:

I use this cgroups package.

There are two interfaces I am interested in for type Cgroup. The one is Freeze() error and the other is Thaw() error.The description of them is as follows:

    ...
	// Freeze freezes or pauses all processes inside the cgroup
	Freeze() error
	// Thaw thaw or resumes all processes inside the cgroup
	Thaw() error
    ...

And there are two linux command that can pause and resume a process, which is kill -STOP pid and kill -CONT pid.

I wonder that if there is only one process in a cgroup, does it has any difference between these two ways to pause and resume the process? Thanks.

答案1

得分: 0

这两个状态是在2016年10月引入的,containerd/cgroups提交b3f3344中提到,并且与cgroup v1 self-state相关。

> cgroup冻结是分层的。
>
> 冻结一个cgroup会冻结属于该cgroup及其子cgroup的所有任务。
每个cgroup都有自己的状态(self-state)和从父级继承的状态(parent-state)。
当且仅当这两个状态都是THAWED时,cgroup才是THAWED。

CGroup Freezer 状态:

> freezer.state 只在非根cgroup中可用,有三个可能的值:
> - FROZEN — cgroup中的任务被挂起。
>- FREEZING — 系统正在挂起cgroup中的任务。
>- THAWED — cgroup中的任务已恢复。

含义(这里):

> 冻结子系统用于挂起和恢复cgroup中的进程。
>
> 冻结器有一个控制文件:freezer.state,将FROZEN写入该文件,可以挂起cgroup中的进程,将THAWED写入该文件,可以恢复挂起的进程。

英文:

Both states were introduced in oct. 2016 in containerd/cgroups commit b3f3344 and refer to cgroup v1 self-state

> The cgroup freezer is hierarchical.
>
> Freezing a cgroup freezes all tasks beloning to the cgroup and all its descendant cgroups.
Each cgroup has its own state (self-state) and the state inherited from the parent (parent-state).
Iff both states are THAWED, the cgroup is THAWED.

CGroup Freezer states:

> freezer.state is only available in non-root cgroups and has three possible values:
> - FROZEN — tasks in the cgroup are suspended.
>- FREEZING — the system is in the process of suspending tasks in the cgroup.
>- THAWED — tasks in the cgroup have resumed.

Meaning (here):

> The freezer subsystem is used to suspend and resume processes in the cgroup.
>
>Freezer has a control file: freezer.state, write FROZEN to this file, you can suspend the process in the cgroup, and write THAWED to this file, you can resume the suspended process.

huangapple
  • 本文由 发表于 2021年9月30日 11:28:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/69385740.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定