Re: Re: Synchronizing Thread Execution
Re: Re: Synchronizing Thread Execution
- Subject: Re: Re: Synchronizing Thread Execution
- From: "Shawn Erickson" <email@hidden>
- Date: Mon, 4 Dec 2006 18:43:31 -0800
On 12/4/06, leenoori <email@hidden> wrote:
El 5/12/2006, a las 1:04, Rosyna escribió:
> http://www.opensource.apple.com/darwinsource/10.3.2/objc4-235/
> runtime/objc-sync.m
>
> http://www.opensource.apple.com/darwinsource/10.3.3/objc4-237/
> runtime/objc-sync.m
>
> Compare and contrast the 10.3.2 code with the 10.3.3 code.
Well, had a look and can't really grok what might be unsafe about the
10.3.2 version... Can you be more specific?
In the implementation mutex instances are held in a linked list... in
essences a cache of mutex that are either in use or available for
reuse. The link list data structure and the bookkeeping data in each
node of the link list are protected by a lock. This is needed so that
a given mutex is used by multiple threads to synchronize critical
sections of code against the same object (pointer, aka the value
supplied to the @synchronized statement).
In the 10.3.2 version however an aspect of the bookkeeping data
(lockCount and object of SyncData) is modified outside of the lock
that protects the the link list and its data. The end result is the
possibility that different threads could use the same mutex instance
to synchronize against different objects instead of using two
different mutex instances like they really should be.
The 10.3.3 version corrects this issue by only modifying / evaluating
the link list and node data while holding the lock that protects that
data.
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden