tag:blogger.com,1999:blog-34442452.post8870067577919202656..comments2023-04-16T03:49:21.961-07:00Comments on Cocoa Samurai: OSSpinLock :: Lock Showdown ( POSIX Locks vs OSSpinLock vs NSLock vs @synchronized )Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-34442452.post-23169740293039022692008-08-25T13:21:00.000-07:002008-08-25T13:21:00.000-07:00@m-g lavoie that's because @synchronized does more...@m-g lavoie that's because @synchronized does more than just provide thread serialization to functions/data structures it also sets up exception handling for your thread ( http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_12_section_1.html#//apple_ref/doc/uid/TP30001163-CH19-SW1 )Colin Wheelerhttps://www.blogger.com/profile/16010768305821496589noreply@blogger.comtag:blogger.com,1999:blog-34442452.post-6692746245966328772008-08-25T12:54:00.000-07:002008-08-25T12:54:00.000-07:00Quick reply :-)Thanks. I stumbled on that page thr...Quick reply :-)<BR/><BR/>Thanks. I stumbled on that page through Google and didn't have a reference point linking to article.<BR/><BR/>Well, I looked at the code and I thought some of the numbers seemed perhaps inflated by the actual code running behind. From this blog post, one is left with the impression that the execution time is spent mostly on the locks. I thought those numbers felt high. Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34442452.post-65544241005438159212008-08-25T11:29:00.000-07:002008-08-25T11:29:00.000-07:00@m-g lavoie the link to the apps source code is in...@m-g lavoie the link to the apps source code is in the article if you clicked the Cocoa-Dev link your brought straight to the page with the source code. The link is also here ( http://www.cocoadev.com/index.pl?LockingAPIs )Colin Wheelerhttps://www.blogger.com/profile/16010768305821496589noreply@blogger.comtag:blogger.com,1999:blog-34442452.post-68961393305998668102008-08-25T08:52:00.000-07:002008-08-25T08:52:00.000-07:00Any way to get a hold of this test app so we can c...Any way to get a hold of this test app so we can compare the same code on various architecture?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34442452.post-40627855553204262682008-04-18T07:59:00.000-07:002008-04-18T07:59:00.000-07:00sorry, I was not that clear.I worked on a debuggin...sorry, I was not that clear.<BR/>I worked on a debugging tool similar to ObjectAlloc.<BR/>and when collecting information (for example the stack trace), I had to lock during the retain and release.Anonymoushttps://www.blogger.com/profile/17133997864602166374noreply@blogger.comtag:blogger.com,1999:blog-34442452.post-84888991587834004472008-04-16T21:14:00.000-07:002008-04-16T21:14:00.000-07:00Regarding the times between using @synchronized an...Regarding the times between using @synchronized and the others, surely the difference is negligible in the example you give.<BR/>As a user, I don't want to wait 5 seconds <I>or</I> 2.8 seconds. Ideally, it shouldn't happen. So the task should be taken away from the main thread.<BR/><BR/>But looking at the figures, these things are taking fractions of microseconds each! Surely the tasks that they Unknownhttps://www.blogger.com/profile/04170433128830993379noreply@blogger.comtag:blogger.com,1999:blog-34442452.post-47050435839763022432008-04-16T20:38:00.000-07:002008-04-16T20:38:00.000-07:00hoà, have you seen the OSAtomic... functions?For t...hoà, have you seen the OSAtomic... functions?<BR/><BR/>For the retain count example, you can do: (please paste into a text editor, I can't use the code or pre tags here!)<BR/><B><BR/>// Assuming an instance variable of: unsigned int _retainCount;<BR/>// In Leopard, the value returned by -retainCount should be an NSUInteger. However, the value of UINT_MAX signifies a special case (an unreleasable Unknownhttps://www.blogger.com/profile/04170433128830993379noreply@blogger.comtag:blogger.com,1999:blog-34442452.post-29994478225868863882008-04-16T02:03:00.000-07:002008-04-16T02:03:00.000-07:00strange results.When working on a tool to count re...strange results.<BR/>When working on a tool to count retain/release in a Cocoa App, OSSpinLock() proved so much faster than pthread_lock().Anonymoushttps://www.blogger.com/profile/17133997864602166374noreply@blogger.com