Paul Rubin wrote: > "Jeff M." <mass...@gmail.com> writes: >> > > Even the lightest weight >> > > user space ("green") threads need a few hundred instructions, >> > > minimum, to amortize the cost of context switching.... >> There's always a context switch. It's just whether or not you are >> switching in/out a virtual stack and registers for the context or the >> hardware stack/registers. > > I don't see the hundreds of instructions in that case. > > http://shootout.alioth.debian.org/u32q/benchmark.php?test=threadring&lang=ghc&id=3 > > shows GHC doing 50 million lightweight thread switches in 8.47 > seconds, passing a token around a thread ring. Almost all of that is > probably spent acquiring and releasing the token's lock as the token > is passed from one thread to another. That simply doesn't leave time > for hundreds of instructions per switch.
And Haskell is not exactly fast... -- Dr Jon D Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?u -- http://mail.python.org/mailman/listinfo/python-list