Re: Lock-free protocols? Making circular buffers.
Re: Lock-free protocols? Making circular buffers.
- Subject: Re: Lock-free protocols? Making circular buffers.
- From: Andre Lipinski <email@hidden>
- Date: Mon, 22 Apr 2002 14:43:05 -0400
Hi,
Buffer passing without locks is best done with a circular buffer IMHO.
A circular buffer is most easily described as a structure of mostly a
contiguous lump of memory big enough to hold x samples plus a read-to
pointer and a write-at pointer, and a way to remember what x is. One
process always writes to the buffer, it always increments write-at after
each write (and circles to the beginning when it hits the end and always
stops before read-to) another process always reads and reads up to
write-at, incrementing it's pointer and circling to the beginning too.
The trick is to use atomic operations for the incrementing, like
IncrementAtomic() from CoreServices/DriverSynchronization.h.
That ought to do ya.
Andre.
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.