Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: time to sleep?
From: Paul Suade (paul.suade_at_laposte.net)
Date: 2002-08-24


----- Original Message -----
From: "Sven Karlsson" <svenka_at_it.kth.se>
To: <rockbox_at_cool.haxx.se>
Sent: Thursday, August 22, 2002 2:22 PM
Subject: Re: time to sleep?

> 1. Write very efficient code. Every cycle wasted in vain is power wasted!

algorithmic speaking ?

> 2. Do not access memory if not needed. Memory accesses actually take a lot
> of power. There are a lot coding tips one can use to minimise the amount
of
> memory accesses performed here are a few:
> * Use the "register" keyword whenever possible.

"register" is no use with gcc since itself will try to put the first local
variables in registers (not always a good thing by the way...)

> * Use the "restrict" keyword whenever possible. This keyword was just
> recently introduced into the ANSI C spec.

exactly, it is now part of ANSI C like bool is too.

> * Use the "const" keyword whenever possible.

and a good practice : you know if you are right to modify the content.

> * Don't count on the compiler doing obvious optimizations for you. The
> compiler might not "see" them. It is always a good idea to look at the
> assembly code generated by the compiler. You might be surprised!

The only bemol is that you need to be a good assembly programmer too ;).

> 3. Never busy wait for a long time. Use interrupts or go to sleep.

Obviously.

> 4. Never use interrupts for short timeouts. If you know the timeout is
just
> a few microseconds then wait that amount of time using a loop and then
busy
> wait. This often consumes less power.

And much more simple to program too. In fact, using a timer interrupt to
wakeup would demand for installing a handler and setting a timeout which
takes much more time to do so and ruin cache effort (if you cpu has ICACHE
of course), spoiling power.

> 5. Don't touch IO chips if can avoid it. The busdrivers often consume a
bit
> of power. This also applies to a lesser degree to microcontroller on-chip
> IO. Remember that IO devices consume a bit of power when being poked at.
> IIRC LCDs consume a lot more power when you change the screen contents
than
> when they are static.

In short, simply toggle i/o bit when necessary.

Well, I suppose it is not an evidence for all people, especially for those
who only program in higher level language to respect all those rules. :/



Page was last modified "Jan 10 2012" The Rockbox Crew
aaa