Avoid polling

From Green software

Revision as of 14:42, 16 September 2010 by Green (Talk | contribs)
Jump to: navigation, search

Polling is regularly checking to see whether a certain condition has been met. It can be used for example to see whether a network message has come in or user input is ready for processing.

Instead of polling, an event based system can be used for more energy efficiency.

Often a good performance results in energy savings. Polling is one of the few mechanisms that performs equally well as alternatives, but is more energy consuming.



Alternatives to constant polling are less frequent polling, signals, events or push.

Signals and events


Less frequent polling

The less frequent polling is done, the better. This is not always possible, but there is a special case for polling frequency. Polling less frequent than the operating system's kernel schedule, is considerably much more energy efficient. For example for Windows systems, it is adviced to poll not more often than every 15 ms [1].

Flexible timers

In Windows 7 it is possible to introduce a variable in a timer schedule, so that the operating system can schedule it in the most energy efficient way possible. The operating system will try to schedule timed events together, or close to the actual kernel events. Considerable amounts of energy can be saved with this technique, because the CPU can spend more time being idle with no extra startup in between kernel jobs. In Windows 7 this technique is called timer coalescing [1].

In Linux systems the round_jiffies() system call does almost exactly same thing.

The Heartbeat Daemon that runs on the Nokia operating system Maemo for mobile phones wakes up applications on requested intervals. The daemon also internally groups the wakeups together in order to save power. Here no further action by the software developer is needed.



[1]. Timers, Timer Resolution, and Development of Efficient Code. 2010. Microsoft Corporation.


This best practice was recognized as such by IT professionals, described in Energy efficient software.
This best practice is mentioned in:
Petter Larsson. 2008. Energy-Efficient Software Guidelines. White Paper for the Intel Software Solutions Group.

Personal tools