Re: Tricks to avoid mutexes
Re: Tricks to avoid mutexes
- Subject: Re: Tricks to avoid mutexes
- From: Jim Wintermyre <email@hidden>
- Date: Wed, 19 Jan 2005 03:49:27 -0800
The MT-SMP list might be a more appropriate place for this question,
but I'll throw out a few comments:
I'm working on an AudioUnit.
I'd basically like to know if storing an int/float/double is atomic.
Int store should be atomic, not sure about float/double. There are
also the OSAtomic functions you could use which would be lighter
weight than mutexes.
More exactly, if the storing instruction does comit all bytes into memory at
once.
For a mono cpu this is most likely true, since a context change cannot
happen in the middle of an instruction (afaik). I don't mind if a thread
gets an old copy of the data: I just don't want it to get a corrupted copy.
What happens for a dual cpu? When one is storing to memory and the other is
reading from it, is it possible that it might get an half new/half old copy?
I guess the question is: does both cpu can access the memory at the same
time ? Even if one is writing to it? When one cpu write, the cache line for
the other has to be updated..
Mac HW is cache-coherent, so you should not need to worry about this.
I know it isn't good programming style to rely on such specific behavior,
but I'd like to avoid waiting a complete audio render cycle before applying
new paramaters.
On the other hand, you may not necessarily want to apply param
updates at any arbitrary sample time. You might consider a separate
lower param update rate.
Jim
_______________________________________________
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