ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> zodb
zodb
Re: [ZODB-Dev] Locking
by Izak Burger other posts by this author
Jul 4 2008 1:09AM messages near this date
[ZODB-Dev] Locking | Re: [ZODB-Dev] Locking
Joseph Turian wrote:
>  See if key is present in root.
>  [it's not]
>  Lock key write-access, so that no other client will try to write key.
>  Compute value for key.
>  Write value for key.
>  Unlock key.

Just as an aside, theoretically speaking, checking for the existence of 
the key should be included in the critical section (the area protected 
by the lock), otherwise you create a race condition.

Example: process/thread A checks for a key and doesn't find it, A is 
preempted and process/thread B is scheduled, B checks for the same key 
and sees that it doesn't exist. B enters the critical section and 
creates the key. Next, A is scheduled by the OS and enters the critical 
section and tries to create the same key. Not good.

But as was already explained, all you need to do is check for a conflict.

Cheers,
Izak
_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@[...].org
http://mail.zope.org/mailman/listinfo/zodb-dev
Thread:
Joseph Turian
Izak Burger
Marius Gedminas
Andreas Jung

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved