[Python-Dev] marking shared-ness (was: baby steps for free-threading)

Greg Stein gstein@lyra.org
Wed, 19 Apr 2000 13:27:11 -0700 (PDT)


On Wed, 19 Apr 2000, Salz, Rich wrote:
> >In my experience, allowing/requiring programmers to specify sharedness is
> >a very rich source of hard-to-find bugs.
> 
> My experience is the opposite, since most objects aren't shared. :)
> You could probably do something like add an "owning thread" to each object
> structure, and on refcount throw an exception if not shared and the current
> thread isn't the owner. Not sure if space is a concern, but since the object
> is either shared or needs its own mutex, you make them a union:
> 	bool shared;
> 	union {
> 		python_thread_id_type id;
> 		python_mutex_type m;
> 	};
> 
> 
>   (Not saying I have an answer to
> the performance hit of locking on incref/decref, just saying that the
> development cost of 'shared' is very high.)

Regardless of complexity or lack thereof, any kind of "specified
sharedness" cannot be implemented.

Consider the case where a programmer forgets to note the sharedness. He
passes the object to another thread. At certain points: BAM! The
interpreter dumps core.

Guido has specifically stated that *nothing* should ever allow that (in
terms of pure Python code; bad C extension coding is all right).

Sharedness has merit, but it cannot be used :-(

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/