[gambit-list] Problem in thread-sleep! may be a poor implementation of the select system call
Marc Feeley
feeley at iro.umontreal.ca
Tue Jan 27 20:36:38 EST 2009
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: select-test.c
Type: application/octet-stream
Size: 1394 bytes
Desc: not available
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20090127/aed94640/attachment.obj>
-------------- next part --------------
More information about the Gambit-list
mailing list