[haiku-development] Re: On timeslices and cycles

  • From: Christian Packmann <Christian.Packmann@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 13 Mar 2009 13:08:37 +0100

Axel Dörfler - 2009-03-13 12:28 :
Christian Packmann <Christian.Packmann@xxxxxx> wrote:
Oh, and fixing CPU affinity would also allow me for writing proper benchmarking tools without having to worry about core hopping, so I'm not quite neutral in this matter. ;-)

CPU affinity does not avoid CPU hopping - it just makes it happen much less often.

You're talking about soft affinity, which should be an inherent part of a good scheduler - try to keep a thread on the same CPU as long as possible. Affinity settable by OS calls usually is hard affinity, i.e. the thread will run only on the given CPU(s), when multiple CPUs are given in the affinity mask, the OS is free to schedule the thread on any of the CPUs as it sees fit.

A good introduction to this for Linux: http://www.linuxjournal.com/article/6799

And hard affinity is a requirement in some cases. E.g. when I want to get reliable Time Stamp Counters (or PMC) measurements on a Barcelona/Phenom, I need to use hard CPU affinity for a single core, as the CPUs will have varying frequencies and thus TSCs per core. I'm currently considering just switching off all CPUs/cores but one on Haiku, as this is the only way to get reliable measurements.

Christian

Other related posts: