• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iTunes stuttering, and don't shoot me--it might involve Core Audio
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iTunes stuttering, and don't shoot me--it might involve Core Audio


  • Subject: Re: iTunes stuttering, and don't shoot me--it might involve Core Audio
  • From: Jim Wintermyre <email@hidden>
  • Date: Sat, 13 Aug 2005 01:56:10 -0700

It does raise a question I have been meaning to ask: Is there some way to hint to the OS that in the near future, a particular page of memory is going to be needed so the VM engine could have it ready in physical ram for the next core-audio render cycle?

Yes there is.

First use valloc() function to allocate page aligned memory.
Then use mlock() function to lock this memory, this memory will not
be swapped out, also this function guaranties that all pages actually
point to physical memory.

Use munlock() to unlock this memory and free() to free the memory.

I use this for the ring buffer of my audio recording application,
also at the end of the io cycle after you've written into the ring
buffer, one should call OSMemoryBarrier() to flush the cpu cache to
the ring buffer. This so that the thread that reads from the ring
buffer will actually get data on multi cpu machines.

I don't think you need OSMemoryBarrier() for cache flushing purposes. All Mac OS MP machines are cache-coherent, meaning that any access to an address from one CPU will ensure that the cache is flushed if the data being accessed resides in the other CPU's cache. However, you may need OSMemoryBarrier() in order to ensure that all I/O has actually completed at a certain point, because the hardware can reorder read/write operations (this is especially true on the G5). If you're doing a write, and the write is an atomic operation (say, writing a long, or you use one of the OSAtomic routines), then you can put in an OSMemoryBarrier() call if you need to ensure that this value actually gets physically written before any further IO (such as a read) occurs later in the code, which otherwise could actually get reordered to occur before the write happens in the hardware.


In the case where you're dealing with writes to hardware instead of memory, the corresponding function is OSSynchronizeIO(), which on the PPC executes everyone's favorite PPC instruction, "eieio" (enforce in-order excecution of IO).

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


  • Prev by Date: Bug in IOAudioStream?
  • Next by Date: DFX AU Utilities library update
  • Previous by thread: Re: iTunes stuttering, and don't shoot me--it might involve Core Audio
  • Next by thread: Re: iTunes stuttering
  • Index(es):
    • Date
    • Thread