Mac OS X Kernel Extension CPU Selection -


i reading source code model-specific register (msr) driver kernel extension ships intel performance counter monitor (http://software.intel.com/en-us/articles/intel-performance-counter-monitor-a-better-way-to-measure-cpu-utilization). since independent copies of msrs/performance counters stored on different cpus, necessary specify cpu read from. done calling mp_rendezvous_no_intrs function.

mp_rendezvous_no_intrs(cpureadmsr, (void*)idatas); 

this causes each processor check if correct processor number, , if read data msr:

void cpureadmsr(void* pidata){     pcm_msr_data_t* data = (pcm_msr_data_t*)pidata;     volatile uint cpu = cpu_number();     if(data->cpu_num == cpu)     {         data->value = rdmsr(data->msr_num);     } } 

my question is: turning off interrupts (via mp_rendezvous_no_intrs it) enough cause thread running cpureadmsr function stay on same cpu whole time? if not, worry following failure scenario:

  1. the cpu reads numerical id cpu_number(), decides correct cpu, , starts read msr.
  2. the thread preempted scheduler , moved different cpu.
  3. the msr read, read different cpu, giving wrong value.

disabling interrupts disables interrupts, not of them. includes timer interrupt, allows running thread preempted.

while interrupts disabled, nothing (short of crazy cpu exception) can interrupt code running, start finish, on single cpu.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -