Openmoko Bug #2091: batget polls lots too often
Openmoko Public Trac
bugs at docs.openmoko.org
Tue Oct 28 04:13:58 CET 2008
#2091: batget polls lots too often
---------------------+------------------------------------------------------
Reporter: Viddy | Owner: openmoko-devel
Type: defect | Status: new
Priority: normal | Milestone: FSO
Component: unknown | Version: FSO-MS2
Severity: normal | Keywords: batget,polling
Haspatch: 0 | Blockedby:
Estimated: | Patchreview:
Blocking: | Reproducible:
---------------------+------------------------------------------------------
A strace of
/usr/lib/enlightenment/modules/battery/linux-gnueabi-arm/batget
while it is running produces the following output, repeated:
Command to get ouput:
ps ax|grep batget|grep -v grep|awk '{print $1}'|xargs -n1 strace -Ff -p
Output:
open("/sys/class/power_supply/bat/current_now", O_RDONLY|O_LARGEFILE) = 6
fstat64(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x4001e000
read(6, "-43125\n", 4096) = 7
close(6) = 0
munmap(0x4001e000, 4096) = 0
open("/sys/class/power_supply/bat/status", O_RDONLY|O_LARGEFILE) = 6
fstat64(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x4001e000
read(6, "Charging\n", 4096) = 9
close(6) = 0
munmap(0x4001e000, 4096) = 0
open("/sys/class/power_supply/bat/time_to_full_now", O_RDONLY|O_LARGEFILE)
= 6
fstat64(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x4001e000
read(6, "0\n", 4096) = 2
close(6) = 0
munmap(0x4001e000, 4096) = 0
open("/sys/class/power_supply/bat/charge_now", O_RDONLY|O_LARGEFILE) = -1
ENOENT (No such file or directory)
gettimeofday({1225162448, 995725}, NULL) = 0
select(6, [4 5], [], [], {0, 254907}) = 0 (Timeout)
gettimeofday({1225162449, 257579}, NULL) = 0
gettimeofday({1225162449, 260369}, NULL) = 0
open("/sys/class/power_supply/bat/capacity", O_RDONLY|O_LARGEFILE) = 6
fstat64(6, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x4001e000
read(6, "100\n", 4096) = 4
close(6) = 0
munmap(0x4001e000, 4096) = 0
Count of calls, and time taken:
root at om-gta02:~# strace -fF -p 1416 -c
Process 1416 attached - interrupt to quit
Process 1416 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.004264 102 42 mmap2
0.00 0.000000 0 41 read
0.00 0.000000 0 52 10 open
0.00 0.000000 0 41 close
0.00 0.000000 0 32 gettimeofday
0.00 0.000000 0 41 munmap
0.00 0.000000 0 11 select
0.00 0.000000 0 42 fstat64
------ ----------- ----------- --------- --------- ----------------
100.00 0.004264 302 10 total
I appreciate that the easiest way to check the battery status is to poll
the device every so often, and inotify is more challenging to use, but
a) polling multiple files n times per second isn't a good idea, and b)
there really isn't any point in polling the battery while the screen is
off
Suggestions:
use sleep()
if screen is off, sleep() longer
if screen comes back on, wake up process, get it to update battery, go
back to sleep for a few seconds/minutes
Given that battery indicator is a four bar or percentage indicator, a
calculation on how long to sleep for given current capacity and discharge
rate divided by a fudge factor should give the time to sleep for before
any meaningful change in the indicator would be seen by the user.
--
Ticket URL: <https://docs.openmoko.org/trac/ticket/2091>
docs.openmoko.org <http://docs.openmoko.org/trac/>
openmoko trac
More information about the buglog
mailing list