threads

Alex Maranda amaranda at nospam.com
Thu Apr 15 05:29:18 EDT 1999


Gordon McMillan wrote:
> 
> Eric Lee Green writes:
> 
> > Ah. Okay. So Python is doing user-land threads and not Posix
> > (OS-level) threads?
> 
> Nope. Those are OS threads. It's just that there's an interpreter
> lock, which only gets released every N byte-code instructions.
This is kind of misleading. Posix threads can be both user level or
kernel level, depending on the contention scope passed to
pthread_create() (PTHREAD_SCOPE_PROCESS/PTHREAD_SCOPE_SYSTEM).
excerpt from Python-1.5.2/Python/thread_pthread.h:

/* set default attribute object for different versions */

#if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D7)
#  define pthread_attr_default pthread_attr_default
#  define pthread_mutexattr_default pthread_mutexattr_default
#  define pthread_condattr_default pthread_condattr_default
#elif defined(PY_PTHREAD_STD) || defined(PY_PTHREAD_D6)
#  define pthread_attr_default ((pthread_attr_t *)NULL)
#  define pthread_mutexattr_default ((pthread_mutexattr_t *)NULL)
#  define pthread_condattr_default ((pthread_condattr_t *)NULL)
#endif

On my machine, Solaris2.5.1, I'm pretty sure it goes on #elif, so I get
a null ptr (defaults to user level threads). It doesn't matter on SMP
machines anyway because of the interpreter lock.
BTW, any estimate (Guido?) on when will the interpreter be fully
reentrant? (1.6? 2.0?)

Cheers,
-- 
Alex Maranda         mailto: amaranda at spider dot com
Spider Software Ltd. Tel: +44 (0)131 4757036
Edinburgh, UK        http://members.xoom.com/Alex_Maranda
STREAMS based communications protocols for embedded systems




More information about the Python-list mailing list