threading.py -> winthreading.c : Some results

David Bolen db3l at fitlinxx.com
Wed Jan 2 13:07:39 EST 2002


Paul Rubin <phr-n2002a at nightsong.com> writes:

> "Tim Peters" <tim.one at home.com> writes:
> > However, Python's internal uses of locks-- and particularly the
> > GIL --don't need these unusual (relative to what platforms usually
> > offer in the way of native synch gimmicks) semantics.  The GIL is
> > "owned": a thread T that acquires the GIL won't try to acquire it
> > again while it's acquired, T will eventually release it itself,
> > and no other thread will attempt to release it while T has it
> > held.  Most platforms have a more efficient synch implementation
> > for this simple usage, but we never got around to creating an
> > internal lock type to exploit this.  Just about *any* mutex
> > gimmick would suffice except for a spin lock (the GIL can be held
> > by a thread for an arbitrarily long time): the GIL exists solely
> > to enforce serialization.
> 
> Is it feasible to replace the GIL with something else, that allows
> Python programs to use the parallelism on multi-cpu systems?

Theoretically, sure, but that's a ton more work than just providing a
native GIL.  The GIL provides the assurance that no two executions of
Python core code occur simultaneously, and most of the Python core is
written with this specific assumption, so any change to that
assumption would also mean a far reaching set of changes to much/most
of the core code.  You also have the potential overhead for
introducing the extra fine grained checking, which might actually slow
things down in the (currently) more typical single-CPU system.

Whether or not the work falls into the "feasible" category probably
depends on someone having the time and resource to work on it - from
prior discussions on the subject my guess is nobody yet qualifies :-)

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list