NSLock locking order;
NSLock locking order;
- Subject: NSLock locking order;
- From: "Matt Budd (Madentec)" <email@hidden>
- Date: Thu, 10 Nov 2005 11:37:15 -0700
Hello all,
Say I have three threads competing for the same NSLock. Here's some
small psuedo code:
Thread A, B, and C (just with different "<stuff>")
--------------------------------------------------------------
while (YES) {
[_oLock lock];
<stuff>
[_oLock unlock];
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow:
0.5]];
}
So lets say thread A got the the lock first, and then then got
swapped out while doing "<stuff>". Then thread B blocks attempting to
acquire the lock. Then thread C runs and also blocks attempting to
acquire the lock. Then we get back to thread A and it finishes its
"<stuff>", unlocks the _oLock, and sleeps for half a second.
Is there any order to who will get to acquire the lock next? Does
thread B get it because it is queued up somewhere in the foundation's
NSLock class that it is first? Or is there a possibility that thread
A might finish its sleep and loop around and obtain the lock again?
Or does thread C have a chance?
Thanks for any info...
- Matt
_______________________________________________
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