Atomic operations (was Re: [Python-Dev] Why did Fredrik leave the party?)

Jeremy Hylton jeremy@zope.com
Thu, 6 Feb 2003 12:05:29 -0500


>>>>> "BAW" == Barry A Warsaw <barry@python.org> writes:
  BAW> Except that it's not, because of the lack of atomic
  BAW> acquire-and-enter-try.

  BAW> You could probably code this specific example like so:

  BAW>     try:
  BAW> 	lock.acquire() dosomething()
  BAW>     finally:
  BAW> 	try:
  BAW> 	    lock.release()
  BAW> 	except NotLocked:
  BAW> 	    pass

  BAW> but you still have the problem of ironclad resource release in
  BAW> other situations, such as the cursor opening scenario (I think)
  BAW> I posted before.

  BAW> Brett (I think) suggested that there may be alternatives to a
  BAW> syntactic approach, e.g. one that prohibits thread switching
  BAW> between the resource acquisition and the entering of the try.
  BAW> That might be interesting to explore, but I worry about
  BAW> deadlock possibilities.

There was a good paper on this subject at LL2.  You can find it here:
http://www.cs.williams.edu/~freund/papers.html

Jeremy