threadDelay problem

Simon Marlow simonmar at microsoft.com
Wed Jan 7 12:38:11 EST 2004


 
> The idea is to stop a Haskell prog with no runable threads or events
> to process hogging CPU time. I was a bit dissapointed to find 
> that despite
> this on my (otherwise idle) machine the above code was still 
> using 96% of cpu time.
> 
> But fiddling about a bit I found that by changing the thread 
> delay in the
> main loop to 20 mS the CPU usage dropped to 1% or so, which 
> is much more
> acceptable (well it did say 1/50 th second accuracy in the docs :-).

Yes, threadDelay will round the interval down to the nearest multiple of
the resolution, so you were effectively using threadDelay 0.  This ought
to be mentioned in the documentation.

Cheers,
	Simon


More information about the Glasgow-haskell-users mailing list