Sun Jun 7 02:56:52 EDT 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.
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