Re: Locking/synchronization conundrum
Re: Locking/synchronization conundrum
- Subject: Re: Locking/synchronization conundrum
- From: Derrick Bass <email@hidden>
- Date: Fri, 17 Mar 2006 11:30:02 -0600
On Mar 17, 2006, at 10:35 AM, Matt Gough wrote:
The problem with this though is that it prevents multiple threads
calling fruitForKey: even if no-one is trying to call
setFruit:forKey. I only need to prevent more than one thread at a
time accessing the dictionary if one (or more) of them is trying to
modify it using setFruit:forKey:.
Is there a general solution to this problem?
This is a classic synchronization problem called the "readers-
writers" problem. It should be covered in any good operating systems
book (I'm a Tannenbaum fan, myself). If I recall, the usual solution
involves semaphores, which can be easily emulated on Cocoa using
NSConditionLock.
In a Google search, it can be hard to wade through all the research
papers to find the well-accepted solutions. I found one useful
looking link in a quick Google: <http://greenteapress.com/semaphores/>.
Derrick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden