Low power design, until only recently, would have been considered purely a hardware issue, but it is now very much on the agenda for software developers. The thinking is simple: the software “knows” what is required of a device at any given moment, so it is well placed to determine which resources are required and make them available.
There are essentially two contexts in which a device's power consumption may be considered: when it is in use and when it is idle. During use, there are a couple of measures that software can take to keep power consumption to a minimum:
- Switch off peripherals that are not in use so that their power drain is eliminated.
- Adjust the frequency and voltage of the CPU according to the current performance requirements – "Dynamic Voltage and Frequency Scaling" or DVFS. The CPU performance is directly associated with its power consumption.
Although power management may be implemented in application code, this is awkward and not very logical. It makes much more sense for the operating system to include a power management framework, as the correct operation of drivers, in particular, may be drastically affected by power saving measures and the OS can readily manage this.
When an embedded device is not in use, it may be switched off entirely. This requires little in the way of software support, although sometimes status information may need to be saved on power down. The only problem is that a fully powered down device may take some time to start up. Even with a lightweight RTOS, modern large applications can take many seconds to boot. The alternative to power down is some kind of sleep mode.
We are all familiar with the two sleep modes used by most laptops:
Standby - The CPU and peripherals are shut down, but power is maintained to RAM. This mode has the advantage that wake-up is very fast, but the downside is that power continues to be drawn, so there is a limit on how long a device can be in standby mode before the battery is depleted.
Hibernate - Data is written out to (disk) storage and the system shut down. This mode has the advantage that there is no ongoing power drain, so the hibernated state can be sustained indefinitely. However, wake-up takes longer, as data needs to be copied back into RAM, but this is still much faster than a cold boot.
These modes are not mutually exclusive. Commonly a system in standby mode will automatically go to hibernate are a specific time has elapsed.
Microprocessors and MCUs that are used for embedded applications commonly include a variety of sleep modes, which largely resemble those used by a laptop. Clearly, the key requirement is for these modes to be supported and fully implemented by the RTOS power management framework.