Waiting is an extremely common pattern in software development. Applications have to wait for user input or for data to be ready for processing. Embedded programs communicate with peripheral devices and need to know when data can be read from the device and when the device is ready to accept data.
Often, developers use variations of the polling technique for waiting. They check a device-specific availability flag in a loop, and when it is set to true by the device, they proceed with reading or writing data.
Though this approach is easy to implement, it is inefficient from the perspective of power consumption. When a processor is constantly busy looping around a flag check, it cannot be put into a more power-efficient mode by the operating system power manager. Based on the load, the Linux ondemand frequency governor that we discussed earlier can even decide...