Re: Where is atomicqueue?
Re: Where is atomicqueue?
- Subject: Re: Where is atomicqueue?
- From: Terry Lambert <email@hidden>
- Date: Mon, 28 Apr 2008 12:36:56 -0700
On Apr 28, 2008, at 4:31 AM, Army Research Lab wrote:
On 4/24/08 3:17 PM, "Terry Lambert" <email@hidden> wrote:
Short answer:
(1) It's protected by #ifdef __ppc__, so it's PPC only
(2) It's in a header <libkern/OSAtomic.h>, so you should only
_expect_
to be able to use it in the kernel; the fact that there are some
inline functions there notwithstanding
(3) The atual implementaiton is as an external symbol in the Libkern
and System6.0 exports for PPC only
So to get at it you will need to be linked against the kernel (you
will need to be either kernel code or a KEXT), you will need to be
running PPC-only, and you will need to declare an explicit dependency
for your KEXT on an exported symbol set or on the entire kernel.
OK, are there spinlocks in user space? I want to try a couple of
experiments with some code, just to see if pthread_mutex_lock() is
better,
or if spinlocking is better.
If you use
nm /usr/lib/libSystem.B.dylib
you can probably answer these questions for yourself.
For things for which there are not exported prototypes in header
files, there is no explicit support for them. So technically, i386 has
OSAtomicEnqueue(), spin_lock(), et. al., but they are not supported,
as such. You can see their source code in the published Darwin Libc
sources.
The pthread_mutex() is going to be heavier weight than spin locks, but
spin locks spin, which means they will meaninglessly burn CPU cycles,
so "better" is really going to depend on your definition; if you care
about battery life and hold them a long time, the answer will be "no",
and if you are single CPU, the answer may be "they will just cause you
to deadlock". Any spin lock you use, or OSAtomicEnqueue, etc., is
probably not going to be desirable to use in any PTHREAD_SCOPE_SYSTEM
rather than PTHREAD_SCOPE_PROCESS object.
I would recommend you restrict yourself to supported interfaces.
Also, if you want to take an atomicqueue discussion and go off talking
about spin locks, you probably ought to either change the subject to
reflect a general interest in synchronization primitives, or to
explicitly talk about that instead, or the information isn't going to
be indexed properly and someone coming after you is just going to ask
the same questions again.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden