In this chapter, we will look at per-process resource limits—what they are, and why we require them. We will go on to describe the granularity and the types of resource limits, distinguishing between soft and hard limits. Details on how a user (or system administrator) can query and set the per-process resource limits using appropriate CLI frontends (ulimit, prlimit) will be covered.
The programming interfaces (APIs)—practically speaking, the key prlimit(2) system call API—will be covered in detail. Two detailed code examples, querying the limits and setting a limit on CPU usage, will give the reader hands-on experience of working with resource limits.
In this chapter, with regard to resource limits, we will cover the following topics:
- Necessity
- Granularity
- Types—soft and hard
- The resource limits APIs, with example code