> + // 2) The buffer has be "starved" (not being filled as quickly as > needed), > + // and we then wait until the buffer contains some data (1 sec) > again.
This is the second gnash checkin I've seen in a couple of weeks that involves 1-second polling when our code is waiting for some data. The Linux community (and the OLPC community in particular) is trying to fix all the code that does this kind of polling, because it wastes time and energy. Instead, the code should wait until something actually happens, and only wake up then, rather than once a second. The OLPC is designed to be able to power down its CPU chip during any period when the system is totally idle for about a second or more. The kernel knows when processes/threads have asked to wake up, and won't be able to suspend itself and save power, if various threads are waking up once a second. Here's a Fedora bugzilla entry that shows all the programs that are being fixed for this kind of behavior: https://bugzilla.redhat.com/bugzilla/showdependencytree.cgi?id=204948 Instead of waking up periodically and polling: If it's waiting on a file descriptor, then select() or poll() the file descriptor (with no fixed timeout specified). If it's waiting for another thread, then it should wait on a semaphore, or a file descriptor written by that thread, and the other thread should trigger it only when there's actual data to process. If there's really no way to avoid polling, do exponential backoff, such that you wait a second, then if nothing happened, wait two seconds, then four seconds, etc, so that when idle, you rapidly ramp up to sleeping for minutes at a time.) John PS: I realize Tomas's particular checkin wasn't code that polls once a second -- just comments that document the existing 1-second polling. I'm not blaming anybody -- just encouraging all gnash developers to make our threads sleep UNTIL there is something useful for them to do. _______________________________________________ Gnash-dev mailing list [email protected] http://lists.gnu.org/mailman/listinfo/gnash-dev

