An often-posed question that people have about Linux is, how does scheduling work? We will address this question for user space application developers in this chapter in some detail. In order for the reader to clearly grasp important concepts regarding CPU scheduling on Linux and how you can powerfully use this in applications, we will cover essential background information (the process state machine, real time, and so on) as well. This chapter will end with a brief note on how the Linux OS can even be used as a hard, real-time OS.
In this chapter, the reader will learn about the following topics:
- The Linux process (or thread) state machine and, importantly, the POSIX scheduling policies that Linux implements under the hood
- Related concepts, such as real-time and CPU affinity
- How to exploit the fact that, on a per-thread basis, you can program threads...