Re: Threading Question
Re: Threading Question
- Subject: Re: Threading Question
- From: Mark Pauley <email@hidden>
- Date: Wed, 01 Feb 2012 10:00:03 -0800
From the man page:
> The routines OSAtomicEnqueue() and OSAtomicDequeue() operate on singly linked LIFO queues. Ie, a dequeue operation will return the most recently enqueued element, or NULL if the list is empty. The
> operations are lockless, and barriers are used as necessary to permit thread-safe access to the queue element.
I take 'lockless' to mean non-blocking, though I could be wrong. In my honest opinion, I think that creating a good lockless queue from atomic operations and memory barriers is something of a tricky proposition. It can certainly be done, but I would always rather just use a known good implementation. Same goes for any sort of tricky concurrency pattern, it's just too hard to test properly by one's self.
On Feb 1, 2012, at 12:12 AM, Robert Bielik wrote:
> Hi Mark,
>
> Mark Pauley skrev 2012-02-01 01:50:
>> This is exactly what I'm talking about when I speak of the functions available for you in<libkern/OSAtomic.h>
>
> Using OSMemoryBarrier() from <libkern/OSAtomic.h> as Michael pointed out is quite sufficient, and IMHO possibly better, reason why given below.
>
>> For example: OSAtomicEnqueue and OSAtomicDequeue actually provide the non-blocking FIFO behavior described by previous responses.
>
> Are they really non-blocking ? Atomic yes, but non-blocking ? I'm not acquainted with those queue functions, but as I see it from the example you provided, there HAS to be some memory allocation/deallocation going on "under the hood", and that's not permitted in a non-blocking FIFO implementation AFAIK. Am I missing something ?
>
> All the best,
> /Rob
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden