views:

224

answers:

2

Looking for some tutorials or documentation about the more advanced fine tuning of processor management in Objective C for programming in the Mac OS system. Things such as writing a process that works well with other processes and the way the Mac OS handles processes and processor scheduling.

A: 

In short, don't bother. There aren't really facilities available for doing so and for good reason; very few people get it right and it is basically impossible to even get right at all at the user level.

The Mac OS X system is tuned to dole out system resources as applications demand. For your application to be friendly, avoid polling and don't use more CPU than you have to.

The kernel is the only "process" on the system that has enough information to schedule resources appropriately and efficiently.

Beyond that, leave it up to the system.

Addendum 1:

When optimizing for "maximum friendliness", use the performance analysis tools and optimize for a reduction in CPU usage, memory usage and I/O usage. All three are critical.

Memory is probably even more critical than CPU (assuming you aren't egregiously abusing the CPU). Specifically, once a system starts swapping, performance of all applications and whole system responsiveness will evaporate rapidly.

Addendum 2:

Don't optimize anything until you have done the analysis necessary to prove that it needs optimization!

bbum
that was helpful...
shogun
I would agree for most applications most of the time. OTOH there are legitimate reasons IMHO for applications having certain realtime constraints to want to fine-tune scheduling.
Tobias
The # of applications that fall into the category of needing that fine grained of control over scheduling are exceedingly few. Moreso, that requirement is almost always followed by the requirement to tightly control every other app running on the system. If you truly need realtime, you should be looking to a realtime OS. For pseudo-realtime, best to isolate the pseudo-realtime as much as possible, potentially into a KEXT.
bbum
All of which is well well beyond the bounds of the original question. Without significantly more details, an assumption of "you don't need to control scheduling on that fine grained of a level" is almost guaranteed to be safe and correct.
bbum
A: 

The best Mac OS X internals book is Mac OS X Internals: A Systems Approach. You'll find information about mach processes vs BSD processes, threads, and the like. I'm not sure how well it covers scheduling though.

Also, the source is available for Darwin, the core of OS X. Google will help you find it easily.

stuntmouse