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.
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
, writeFROZEN
to this file, you can suspend the process in the cgroup, and writeTHAWED
to this file, you can resume the suspended process.