[Python-Dev] deja-vu .. python locking

Jean-Paul Calderone exarkun at divmod.com
Mon Sep 18 17:22:07 CEST 2006


On Mon, 18 Sep 2006 17:06:47 +0200, Martin Devera <devik at cdi.cz> wrote:
>Martin v. Löwis wrote:
>> Martin Devera schrieb:
>>> RCU like locking
>>>   Solution I have in mind is similar to RCU. In Python we have quiscent
>>>   state - when a thread returns to main loop of interpreter.
>>
>> There might be a terminology problem here. RCU is read-copy-update,
>> right? I fail to see the copy (copy data structure to be modified)
>> and update (replace original pointer with pointer to copy) part.
>> Do this play a role in that scheme? If so, what specific structure
>> is copied for, say, a list or a dict?
>>
>> This confusion makes it very difficult for me to understand your
>> proposal, so I can't comment much on it. If you think it could work,
>> just go ahead and create an implementation.
>
>It is why I used a word "similar". I see the similarity in a way to archieve
>safe "delete" phase of RCU. Probably I selected bad title for the text. It
>is because I was reading about RCU implementation in Linux kernel and
>I discovered that the idea of postponing critical code to some safe point in
>future might work in Python interpreter.
>
>So that you are right. It is not RCU. It only uses similar technique as RCU
>uses for free-ing old copy of data.
>
>It is based on assumption that an object is typicaly used by single thread. 

Which thread owns builtins?  Or module dictionaries?  If two threads are
running the same function and share no state except their globals, won't
they constantly be thrashing on the module dictionary?  Likewise, if the
same method is running in two different threads, won't they thrash on the
class dictionary?

Jean-Paul


More information about the Python-Dev mailing list