Critical sections and mutexes

David Bolen db3l at fitlinxx.com
Thu Oct 25 17:33:20 EDT 2001


<brueckd at tbye.com> writes:

> So assuming the GIL is replaced by a threadsafe Python core, what will
> break in my program with two worker threads appending to the same list?

If you're sure it's a built-in list and that the append operation is
being serviced by C core code (the built-in part could change today,
and with 2.2 even the built-in might be subclassed) then probably
nothing, assuming that the list was the only world within which you
needed the safety (e.g., there was no correlation between a newly
appended entry in the list and any other data structure that needed to
be kept in sync).

But if either of those conditions might not always be true, then you
could potentially run into problems.

As I noted earlier in the thread, there are certainly specific cases
that can be proposed where there shouldn't be a problem, and I agree
that Python pushes the granularity of such cases higher than a
language such as C.

--
-- 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