Discussion:
OSSpinLockInit in OSX
Nathan Sims
2011-05-06 17:36:24 UTC
Permalink
I'm porting some C code from Linux which uses OSSpinLock function calls.
OSX has the same functions (declated in OSAtomic.h):
• OSSpinLockLock()
• OSSpinLockTry()
• OSSpinLockUnlock()

However, OSX is missing this function:

• OSSpinLockInit()

Is there no initialization needed for an OSSpinLock?
Shantonu Sen
2011-05-06 17:40:29 UTC
Permalink
See the header file:

/*! @abstract The default value for an <code>OSSpinLock</code>.
@discussion
The convention is that unlocked is zero, locked is nonzero.
*/
#define OS_SPINLOCK_INIT 0

Shantonu Sen
Post by Nathan Sims
I'm porting some C code from Linux which uses OSSpinLock function calls.
• OSSpinLockLock()
• OSSpinLockTry()
• OSSpinLockUnlock()
• OSSpinLockInit()
Is there no initialization needed for an OSSpinLock?
_______________________________________________
MacOSX-dev mailing list
http://www.omnigroup.com/mailman/listinfo/macosx-dev
Nathan Sims
2011-05-06 17:47:04 UTC
Permalink
Thanks! I hadn't seen that. By the way, are the OSSpinLock* functions preferred over pthread_spin_* functions?
-Nate
Post by Shantonu Sen
@discussion
The convention is that unlocked is zero, locked is nonzero.
*/
#define OS_SPINLOCK_INIT 0
Shantonu Sen
Post by Nathan Sims
I'm porting some C code from Linux which uses OSSpinLock function calls.
• OSSpinLockLock()
• OSSpinLockTry()
• OSSpinLockUnlock()
• OSSpinLockInit()
Is there no initialization needed for an OSSpinLock?
_______________________________________________
MacOSX-dev mailing list
http://www.omnigroup.com/mailman/listinfo/macosx-dev
Loading...