Brian Candler wrote: > Ruby is not a precision real-time environment - and neither are Unix or > Windows for that matter. Certainly not. But even with Ruby microsecond sleep should be possible. > If you really need such a short pause, you could use ruby-inline and > call nanosleep() or usleep() or select() C functions That would interrupt all threads. But it could still be an option for sleeps < 0.01s. I.e. sleep everything > 0.01s with thread_wait_for and switch to usleep for smaller values. Of course it would be nice to somehow get the granularity of the scheduler and switch at that. > loop do > send_packet > precision_sleep(0.001) > end > > then you will certainly send less than 1000 packets per second The situation is indeed similar to the above. I'm also well aware of that problem. It's not really an issue, though as I don't sleep the interval but the time left in the interval (measured from an absolute start, not the last time the event happened). After digging in the code I also understand what happens in that gap. timeval.tv_usec is a long representing microseconds. Those values are rounded down to 0, so I assume it effectively doesn't sleep. Regards Stefan -- Posted via http://www.ruby-forum.com/.