Can you explain how OS X time sharing works?
I've noticed that when I'm running something processor intensive (iTunes while it is converting an AIFF to AAC file for example) that Activity monitor still shows appreciable idle time. I am just curious why this should be. I can understand why a busy program would share time with other active programs but why would a program that is doing something intensive not be given a large chunk of the idle time? Philosophically, why preserve idle time? If most of the idle time is given to one program and a second program became busy then OS X could reassign priorities.
I'm not too concerned with the nuts and bolts, just wondering philosophically why things are setup this way.
As a side issue, is it worth playing with renice (or one of the graphical interfaces for it)?
I'm not too concerned with the nuts and bolts, just wondering philosophically why things are setup this way.
As a side issue, is it worth playing with renice (or one of the graphical interfaces for it)?
Comments
The reason that you are seeing idle time could be many.
Is your system a dual processor? If so the task at hand might only use a single thread. My system is dual 500Mhz G4 and the same process takes 106% - 118% of the CPU time. Which means it might be using two threads one to perform I/O operations to place the data into a buffer for the converter thread to convert, hence the use of more than 100 percent CPU time. For the most part the second CPU stays idle.
Other reasons for idle time would be that the CPU is waiting on another part of the system. If the system doesn?t have enough memory and is paging (swapping) during the task you?ll also most likely see idle time as the CPU is waiting for data to be paged in and out. Same goes if your disk sub system is slow, again the CPU is waiting for data.
There are three main components in a system: CPU, memory and I/O subsystems. It doesn?t sound like your bottleneck is in the CPU so look to the other two and you?ll find your answer.
One other area of contention that can yield idle time would be in the use of mutexs and semaphores, a coding locking mechanism to make sure that threads don?t clobber each other over resources. When a thread attempts to gain access to a mutex that is already in use it goes to sleep until that mutex is released. I.e. the converter thread waits to read the buffer while the I/O thread adds new data to the buffer.