Re: Status of thread module?

Rafael Bracho (rxb@lion.Eng.Sun.COM)
Mon, 21 Mar 1994 11:13:42 +0800

Dan,

> I'm interested in writing a multi-threaded TCP/IP server in python.
> How solid is the thread support in python? I have done a fairly
> thorough search of the code, documentation, FAQ, and stuff available
> through the Web. My impression is that thread support is still pretty
> immature.

That's my impression, too. Thread support has been a big push in
the Solaris 2 program, and it is possible to write significant thread
support in a language now.

> How much does thread support slow down the interpreter?

I don't have numbers, but I've looked a the code. There are several
global variables and such that get locked with a global mutex. That's
bound to slow down the interpreter some -- it's a kernel call.

> What about reentrancy in libc.a on the SunOS platform?

libc is MT-safe since Solaris 2.2, I believe. Certainly Solaris 2.3
has full support for user-level threads.

> About blocking system calls... are these only addressed at the
> level of python functions or at the C bindings? For example, what
> if a builtin extension module calls read() -- will it block all the
> threads?

No, individual threads may block on system calls, i.e., you don't
have to worry about this. The kernel has lightweight processes which
get bound to user-level threads (it's a little more complicated than
that, but that's good enough for this discussion). This means that
a process will not block if one of its threads is waiting on a system
call -- the user-level threads library does further work to ensure
that the process cannot starve by running out of threads and/or lwps.

-Rafael