Threads vs. continuations

"Martin v. Löwis" martin at v.loewis.de
Tue Feb 19 18:16:48 EST 2008


> That's assuming that the threading implemented at the language
> level is actually realized by underlying kernel threading.
> Is/Was it not the case, though, that some languages present
> a threading model to the programmer that is realized in user
> space, but not in the kernel.

You were asking about Python and Java specifically. Python
has been using OS threads as its threading foundation ever
since operating systems started supporting threads (there is
still support for user-level thread libraries in Python,
but I doubt it's still in use anywhere). Java had different
versions of the JVM in the past, one that supported only
user-mode threads, but likewise, these got out of use quite
some time ago.

> ISTR some early implementations
> of Posix Threads that worked that way.  The API was there
> and was correct, but - since everything was actually running
> in user space - when a single "thread" blocked, they all did.

No, not in any good user-mode thread library. E.g. the GNU Pth
library manages to provide user-mode dispatching and provides
wrappers for blocking calls that dispatch to a different thread
if blocking would occur.

> 'Not trying to start a fight here, I'm just curious about the
> current state of that art.  It is the case today that all
> modern language threading is realized over a kernel implementation
> of threading that behaves as you suggest?

I didn't suggest it for all languages, only for Python (or Java),
see your original posting.

Regards,
Martin



More information about the Python-list mailing list