multi-core software

Paul Rubin http
Sun Jun 7 08:56:52 CEST 2009


"Jeff M." <massung at 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.



More information about the Python-list mailing list