Earlier quoted context omitted.
Noisy means there is a lot of variance in the actual time the process spends sleeping. When you say sleep(1) most OSes interpret that as saying, sleep as short as you can. Based on the scheduler internals, that can vary a lot.
Which OS interprets sleep(1) (ie, "sleep for 1 second") as "sleep for as short as you can"? 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…
"A sleep(1) is put into all SSL_read() and SSL_write() calls..."
41–50 of 52 posts
Re: "A sleep(1) is put into all SSL_read() and SSL_write() calls..."
#42Earlier quoted context omitted.
Which OS interprets sleep(1) (ie, "sleep for 1 second") as "sleep for as short as you can"? 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…
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() calls..."
#43Earlier quoted context omitted.
Sleep(1) is very noisy on Windows machines. The time slice given by default is ~15-20ms [1], and calling Sleep( This crummy Sleep() implementation has some nice effects on programmers. Those who like to solve problems with lots of copy/paste code are forced to think about using proper synchronization primitives when running high resolution loops that wait for events, or their code just won't run very fast. [1] http:/…
When I did driver programming in Windows, it was well-known that Sleep had a resolution of 10 ms; it is based on the interrupt timer (not the high frequency timer). You could change the interrupt timer's duration, but its ticks are what guide Sleep. Not counting the effect of context switching, since you are waiting for the timer ticks, your actual times vary from 10 ms to 19.9999 ms. 15 ms is a nice way to say "on a…
Re: "A sleep(1) is put into all SSL_read() and SSL_write() calls..."
#44Earlier quoted context omitted.
cool, I'll check the nic status before sending if I ever want to maximize throughput. But I'll probably rewrite it in C at that point too.
"Check the NIC status"? What network API are you using? Even if you're injecting with libpcap, you can still just select() on the device handle.
Re: "A sleep(1) is put into all SSL_read() and SSL_write() calls..."
#45Earlier quoted context omitted.
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.
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() calls..."
#46Earlier quoted context omitted.
"Check the NIC status"? What network API are you using? Even if you're injecting with libpcap, you can still just select() on the device handle.
I am not using an API, I am writing to the driver
Re: "A sleep(1) is put into all SSL_read() and SSL_write() calls..."
#47Earlier quoted context omitted.
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.
Read it again. He's talking about near-zero sleep calls, not one second sleep calls.
Re: "A sleep(1) is put into all SSL_read() and SSL_write() calls..."
#48Earlier quoted context omitted.
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.
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.
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() calls..."
#49Earlier quoted context omitted.
When I did driver programming in Windows, it was well-known that Sleep had a resolution of 10 ms; it is based on the interrupt timer (not the high frequency timer). You could change the interrupt timer's duration, but its ticks are what guide Sleep. Not counting the effect of context switching, since you are waiting for the timer ticks, your actual times vary from 10 ms to 19.9999 ms. 15 ms is a nice way to say "on a…
Presumably the high frequency counter is driven off the cycle counter, and not the Intel High Precision HPET Timers.
"The issue has two components: rate of tick and whether all cores (processors) have identical values in their time-keeping registers. There is no promise that the timestamp counters of multiple CPUs on a single motherboard will be synchronized. In such cases, programmers can only get reliable results by locking their code to a single CPU."
The entry also mentions that hibernation can affect the counters. I wonder if power savings implementations that speed up or slow the CPU could also have an effect.
Re: "A sleep(1) is put into all SSL_read() and SSL_write() calls..."
#50Earlier quoted context omitted.
Presumably the high frequency counter is driven off the cycle counter, and not the Intel High Precision HPET Timers.
http://en.wikipedia.org/wiki/Time_Stamp_Counter "The issue has two components: rate of tick and whether all cores (processors) have identical values in their time-keeping registers. There is no promise that the timestamp counters of multiple CPUs on a single motherboard will be synchronized. In such cases, programmers can only get reliable results by locking their code to a single CPU." The entry also mentions that h…