4

I've noticed this today - my entire system froze up solid, clock is frozen, nothing responds to clicks and key presses, and my time machine animation stopped going. While repartitioning my boot drive. I also had iTunes open, which happily kept on playing music. How does iTunes manage to keep playing media if the entire OS is frozen up solid? No other OS X media player I've seen can do this, and I'd love to know how this is possible.

Thanks.

Tristan
  • 141
  • 4

2 Answers2

4

I believe iTunes uses real-time threads, which is a certain type of threads which are given constant fraction of time whatever happens on the machine. See this apple doc for a short discussion. You can find more info in the OS X Internal book. The book is a bit dated (it mainly discusses 10.4 Tiger) but the kernel internals haven't drastically changed.

I think other media players don't operate as real-time threads; these days the computers are quite powerful and the music doesn't stop even under the standard scheduling policy, unless you do an extremely kernel-intensive task.

Yuji
  • 346
2

My guess is that when you select a song to play in iTunes, iTunes will push almost all of the raw data for the song into a DMA. Because of the way that I/O devices talk to the CPU, each device has it's own memory address. Once the CPU has finished pushing data to that address, the I/O device can use the data there withou the CPU having to babysit it. So iTunes moves the data for the song to the sound device's memory address and the sound device starts playing it. When the CPU locks up while you're playing a song, the sound device hasn't realized the CPU stopped, and just keeps using the data from its memory address, playing the song.