linux-sysprog · beginner · ~15 min
Compute remaining quota without underflow.
Implement long cgroup_remaining(long limit, long used) returning how much memory is left in a cgroup (limit - used), but never negative (return 0 if over).
long cgroup_remaining(long limit, long used) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.