Exemple #1
0
static void
wait_for_other_cpu (int cpunum)
{
	spinlock_lock (&panic_lock);
	if (paniccpu != cpunum) {
		while (paniccpu != -1) {
			spinlock_unlock (&panic_lock);
			while (paniccpu != -1)
				asm_pause ();
			spinlock_lock (&panic_lock);
		}
		paniccpu = cpunum;
	}
	spinlock_unlock (&panic_lock);
}
void do_idle()
{
   static volatile unsigned long long last_cpu = rdtsc();
   for (;;)
   {
      asm_pause();
      volatile unsigned long long cpu = rdtsc();
      if ((cpu-last_cpu) >= temp.ticks_frame)
          break;

      if(conf.sleepidle)
      {
          ULONG Delay = ULONG(((temp.ticks_frame - (cpu-last_cpu)) * 1000ULL) / temp.cpufq);

          if(Delay != 0)
          {
              Sleep(Delay);
 //             printf("sleep: %lu\n", Delay);
              break;
          }
      }
   }
   last_cpu = rdtsc();
}