Chapter 21: Real-Time Programming
Much of the interaction between a computer system and the real world happens in real time, and so this is an important topic for developers of embedded systems. I have touched on real-time programming in several places so far: in Chapter 17, Learning About Processes and Threads, we looked at scheduling policies and priority inversion, and in Chapter 18, Managing Memory, I described the problems with page faults and the need for memory locking. Now it is time to bring these topics together and look at real-time programming in some depth.
In this chapter, I will begin with a discussion about the characteristics of real-time systems, and then consider the implications for system design, at both the application and kernel levels. I will describe the real-time PREEMPT_RT
kernel patch, and show how to get it and apply it to a mainline kernel. The final sections will describe how to characterize system latencies using two tools: cyclictest and Ftrace.