M. Edward (Ed) Borasky
9/9/2006 7:43:00 PM
Jason Vinson wrote:
> [Somewhat OT]
>
> Have you considered using OS-specific facilities like "cron" instead of
> "sleep" for scheduling? I use cron for most of these periodic, relatively
> low-powered tasks because it is easy to add a task to cron's list of jobs,
> and it burdens the system less than maintaining a bunch of sleeping
> processes -- cron loads, runs, and unloads its tasks, while a sleeping
> process represents an ongoing use of resources.
Amen to that! Anything that is done once a minute or less frequently
should be done with "cron" or the Windows equivalent, whose name I've
forgotten. However, if you need to do something more often than once a
minute, in most cases "sleep" is a perfectly acceptable way to do it.
One caution: most languages and operating systems can't guarantee that
the actual time elapsed between the call to "sleep 10" and the next
operation will be anything even close to 10 seconds. Usually, the
guarantee is that it will be *at least* 10 seconds. :) If you actually
need precise timing, you'll need to dig into the OS, system calls,
priorities, schedulers, etc.