<div dir="ltr">if you care about precise timing (at the cost of of some loss of throughput)<div>you can compile your code with -fno-omit-yields, and also the context switching timer </div><div>see eg <a href="http://www.haskell.org/ghc/docs/7.4.2/html/users_guide/using-concurrent.html">http://www.haskell.org/ghc/docs/7.4.2/html/users_guide/using-concurrent.html</a> </div><div>default context switching rate for threads is -C0.02 (20ms), but you can set the rate as small as you like, and -C0 will trigger a context switch at every yield.</div><div><br></div><div>happy experimenting!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 18, 2014 at 10:19 PM, Brandon Allbery <span dir="ltr"><<a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class=""><div class="gmail_quote">On Sat, Oct 18, 2014 at 9:36 PM, Jeffrey Brown <span dir="ltr"><<a href="mailto:jeffbrown.the@gmail.com" target="_blank">jeffbrown.the@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,sans-serif;font-size:12.5714282989502px">threadDelay is <a href="http://hackage.haskell.org/package/base-4.7.0.1/docs/Control-Concurrent.html#v:threadDelay" target="_blank">guaranteed</a><div style="display:inline-block;width:16px;min-height:16px"> </div> to wait at least as long, but potentially longer than, what the caller specifies. Another potential problem could be buffering in printf. (Eventually I intend to replace the printf statement with OSC output to a sound generator.)</div></blockquote></div><br></span>This isn't going to be solved completely within Haskell; the behavior of threadDelay is the behavior of the system scheduler for a normal process, possibly modified by garbage collection delays. You'll need to switch the process to a realtime scheduling class to remove --- or at least reduce --- the OS's contribution to the uncertainties in sleep times.<span class="HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div dir="ltr"><div>brandon s allbery kf8nh                               sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a>                                  <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad        <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div>
</font></span></div></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>