David St-Hilaire was experimenting with the following program:
(define n 0)
(thread-start! (make-thread (lambda () (let loop () (set! n (+ n 1)) (thread-sleep! .0001) (loop)))))
(thread-sleep! 1)
(pp n) ;; expected value of n is approximately 10000
The value printed for n on his Linux computer is approximately 100. When I try the program on my Mac OS X computer I get a value much closer to the expected 10000.
After digging around it seems that the resolution of the "timeout" parameter to the "select" system call (which is used by the scheduler to wait for I/O and/or a timeout) can vary greatly from one OS to another.
I'm curious to know how well other operating systems handle the timeout. So, if you have access to some unusual operating system, could you try the above program and report back what value is printed?
I also wrote the C program below to test the resolution of select's timeout. You can try that too.
Marc