Re:"A sleep(1) is put into all SSL_read() and SSL_write() ca...
by xpaulbettsx on Friday June 25, 2010 @02:00PM
(#1461506)
Windows also only guarantees that your process will sleep at least as long as you specify. Not that it will sleep exactly as long.
Re:"A sleep(1) is put into all SSL_read() and SSL_write() ca...
by mustpax on Friday June 25, 2010 @02:44PM
(#1461686)
Thanks for the correction. I was just talking about the de facto behavior I have seen on Linux and BSD for very short sleep intervals (way shorter than 1 second), not necessarily about the behavior as specified by the system call. I should have been clearer.
Re:"A sleep(1) is put into all SSL_read() and SSL_write() ca...
by tptacek on Friday June 25, 2010 @02:45PM
(#1461692)
I really don't think you've ever seen BSD return in milliseconds after a 1-second sleep. Respectfully, I think you're pretty much just wrong.
Re:"A sleep(1) is put into all SSL_read() and SSL_write() ca...
by mustpax on Friday June 25, 2010 @03:37PM
(#1461861)
Well, that is not what I meant at all, I meant that I've seen BSD return in say 2 microseconds after calling usleep(1).
But that's usleep not sleep, which is the inaccuracy I was admitting to in the first place.
Re:"A sleep(1) is put into all SSL_read() and SSL_write() ca...
by tptacek on Friday June 25, 2010 @03:42PM
(#1461882)
Ok, but (a) this article is talking about literally POSIX sleep(3), and (b) there is a ton of confusion on this thread about whether sleep is ms-denominated or seconds-denominated.
Sorry to pile on you, though.
Re:"A sleep(1) is put into all SSL_read() and SSL_write() ca...
by Dylan16807 on Friday June 25, 2010 @03:29PM
(#1461833)
Read it again. He's talking about near-zero sleep calls, not one second sleep calls.
On WinAPI, Sleep is denominated in milliseconds.
On BSD, sleep(3) is a library wrapper around nanosleep(2).
Linux's man pages make no mention of the magic number "1" as a "sleep 1 timeslice" shortcut; also, older Linux man pages warn that sleep(3) can be implemented in terms of alarm(1), which is used all over POSIX as an I/O timeout and would blow up the world if it alarmed in milliseconds.
If you want to sleep "as short as you can", sleep for 0 seconds, or call any other system call to yield your process back to the scheduler.