How to go about. On read/write locks

Emanuele D'Arrigo manu3d at
Mon Apr 6 00:51:46 CEST 2009

Hi everybody,

I'm having a threading-related design issue and I suspect it has a
name that I just don't know.  Here's a description.

Let's assume a resource (i.e. a dictionary) that needs to be accessed
by multiple threads. A simple lock will do the job but in some
circumstances it will create an unnecessary bottleneck. I.e. let's
assume that most threads only need to have a -read- access to the
resource, while only few threads actually change the dictionary.
Ideally, the reading threads should not block each other. However, as
soon as a threads intends to change the dictionary it should let all
the reading threads finish, lock the access to the resource, change
it, and then release the lock.

I don't think it'd be difficult to implement but I'm wondering if
something in this direction has been done already, if it has a name or
if it's even well known design pattern.

Anybody can shed some light?


More information about the Python-list mailing list