Laser
Still Fresh
Well it's usually a bad idea for your first forum post to be contentious, but I'm going to anyway! I hope people will take this seriously and discuss the subject in the constructive manner intended. h34r:
For some time I've been following the GP2X scene and am on the verge of buying one. I've some experience of both desktop and embedded development and I love the concept of an open handheld. There is, however, one particular aspect I've seen repeatedly which I feel really gives a bad impression...
Upon downloading the SDK, the curious newbie is presented with some example event-driven SDL code to open a display, listen to the stick, and exit. Fair enough. Except the example busy-waits on an event by using GetEvent() in a loop, rather than the functionally-equivalent WaitEvent() style. I have, sadly, seen this replicated any number of times in the (otherwise highly commendable B) ) programs created by the community.
Why is this a big deal?
I feel the GP2X is struggling with a couple of usability-related issues. 1) Battery life and 2) the frequent advice to mess about with the CPU clock frequencies. Both of these could potentially be lessened by appropriate use of idle-wait-style programming instead of busy-waiting.
The busy-wait style came about when old computers had a single-thread system, or inadequate interrupt resources. Large numbers of MS-DOS programs are written like this. On a desktop machine it makes relatively little difference, although multi-threading performance can be badly affected. On an embedded device, particularly a battery-powered device, arranging the CPU(s) to be inactive when nothing is happening can drastically affect power consumption.
Now, it may be that the SDL Wait does nothing more than internally poll the Get, which of course will get us nowhere. However, if it doesn't already, it certainly could be arranged so that it would halt or idle the CPU until it needed to wake up, assuming the timer, keypad, vsync, etc sources had interrupt capability. During this time there is very little power consumption, reducing the average power consumption of the device.
This also removes the need to find out what the slowest acceptable clock frequency is for any given application, since the device can run at it's maximum rate, but for less time. Only in situations where unsynchronised activity is happening (very rare in an interactive application) and the user is happy to wait longer for it, does the clock speed need to be reduced.
The reduction in the need to educate the average user about CPU clocks is desirable, and if we could extend the battery life by even 10%, it has got to be worth something.
It is entirely likely that some programmers are already using these techniques, but it IMHO it needs to pervade the whole platform, including the system firmware. I would like to hear the opinions of other developers here on this subject. In particular I propose that the SDK examples could be changed to idle-wait models, and the wiki resources updated to educate the new programmer to the benefits. I'd also like to hear from anyone who knows whether the current SDL Wait function(s) idle the processor, or indeed whether the underlying Linux kernel supports this. Since uCLinux is becoming ever more popular for embedded environments, it is reasonable to assume it is feasible.
Thanks for reading. I await your comments with interest! :unsure:
For some time I've been following the GP2X scene and am on the verge of buying one. I've some experience of both desktop and embedded development and I love the concept of an open handheld. There is, however, one particular aspect I've seen repeatedly which I feel really gives a bad impression...
Upon downloading the SDK, the curious newbie is presented with some example event-driven SDL code to open a display, listen to the stick, and exit. Fair enough. Except the example busy-waits on an event by using GetEvent() in a loop, rather than the functionally-equivalent WaitEvent() style. I have, sadly, seen this replicated any number of times in the (otherwise highly commendable B) ) programs created by the community.
Why is this a big deal?
I feel the GP2X is struggling with a couple of usability-related issues. 1) Battery life and 2) the frequent advice to mess about with the CPU clock frequencies. Both of these could potentially be lessened by appropriate use of idle-wait-style programming instead of busy-waiting.
The busy-wait style came about when old computers had a single-thread system, or inadequate interrupt resources. Large numbers of MS-DOS programs are written like this. On a desktop machine it makes relatively little difference, although multi-threading performance can be badly affected. On an embedded device, particularly a battery-powered device, arranging the CPU(s) to be inactive when nothing is happening can drastically affect power consumption.
Now, it may be that the SDL Wait does nothing more than internally poll the Get, which of course will get us nowhere. However, if it doesn't already, it certainly could be arranged so that it would halt or idle the CPU until it needed to wake up, assuming the timer, keypad, vsync, etc sources had interrupt capability. During this time there is very little power consumption, reducing the average power consumption of the device.
This also removes the need to find out what the slowest acceptable clock frequency is for any given application, since the device can run at it's maximum rate, but for less time. Only in situations where unsynchronised activity is happening (very rare in an interactive application) and the user is happy to wait longer for it, does the clock speed need to be reduced.
The reduction in the need to educate the average user about CPU clocks is desirable, and if we could extend the battery life by even 10%, it has got to be worth something.
It is entirely likely that some programmers are already using these techniques, but it IMHO it needs to pervade the whole platform, including the system firmware. I would like to hear the opinions of other developers here on this subject. In particular I propose that the SDK examples could be changed to idle-wait models, and the wiki resources updated to educate the new programmer to the benefits. I'd also like to hear from anyone who knows whether the current SDL Wait function(s) idle the processor, or indeed whether the underlying Linux kernel supports this. Since uCLinux is becoming ever more popular for embedded environments, it is reasonable to assume it is feasible.
Thanks for reading. I await your comments with interest! :unsure: