Challenge, Easy,  on  Linux

Freezing a process lets you safely pause it without stopping or killing it. This can be useful if you want to temporarily suspend a heavy job during peak load, hold a service still while you reconfigure its environment, or "stop the world" so you can inspect the system's state during a security audit or a bug investigation.

In this challenge, you'll launch a resource-hungry program in its own cgroup, freeze it, observe its footprint, and then thaw it back to life.

The binary you'll run is called omnihog - a simple program that greedily consumes CPU and memory when started. Launch it in a dedicated cgroup, freeze (pause) it, take a look around the system (including the process's CPU and memory usage while frozen), and then thaw it back (resume).

Good luck!

Hint: Placing a process in a dedicated cgroup 💡

If you need a refresher on creating cgroups and placing a process into them, revisit this challenge: Limit CPU and Memory Usage of a Linux Process.

Linux control group v2 visualized.
Hint: Freeze (pause) and thaw (resume) a process 💡

In cgroup v2, each cgroup (i.e., a /sys/fs/cgroup subfolder) has a cgroup.freeze file. Freezing all processes in a cgroup is as simple as writing 1 to this file. And to thaw the process(es), you just need to write 0 to the same cgroup.freeze file.

Note that while freezing a cgroup freezes not only all processes in it, but also all processes in all child cgroups, in this challenge, you're expected to freeze the omnihog's own cgroup directly.

Hint: Observe the resource usage while frozen 💡

While frozen, threads do not make forward progress, but they still consume memory. You can inspect the omnihog process's memory and CPU usage while frozen using the ps or a similar command.

Challenge on Linux
Discussion  Discord

Level up your Server Side game — Join 13,000 engineers who receive insightful learning materials straight to their inbox