in reply to making something happen in real time

you could select more frequently and have it check for $t intervals to play the tone, that way your script would be the cpu hog and demand more attention from the system.
  • Comment on Re: making something happen in real time

Replies are listed 'Best First'.
Re^2: making something happen in real time
by bcrowell2 (Friar) on Nov 06, 2005 at 21:58 UTC
    Well, I could just spin in a tight loop instead of using select, but I'd like to avoid having my program be a cpu hog when it shouldn't have any need to be. I don't think sleeping for shorter intervals will help, because it just seems to require several hundred milliseconds to get the cpu back from xscreensaver, and that's a lot longer than the timing resolution I need.
      Well, it sounds like that's what you should do to me. If there's a swinging blade (xscreensaver) and you want to dodge between it (beep) you have to have better time resolution than the period of the pendulum. Maybe you could increase the resolution only near the time when the screensaver should be kicking in? Then, for the majority of the time, you can be less of a cpu hog. That would still leave you vulnerable to anything else that might be going on in your system that also has a high resolution.