1
0

smptest.c 519 B

12345678910111213141516171819202122232425262728293031
  1. #include "libcflat.h"
  2. #include "smp.h"
  3. unsigned nipis;
  4. static void ipi_test(void *data)
  5. {
  6. int n = (long)data;
  7. printf("ipi called, cpu %d\n", n);
  8. if (n != smp_id())
  9. printf("but wrong cpu %d\n", smp_id());
  10. else
  11. nipis++;
  12. }
  13. int main()
  14. {
  15. int ncpus;
  16. int i;
  17. smp_init();
  18. ncpus = cpu_count();
  19. printf("found %d cpus\n", ncpus);
  20. for (i = 0; i < ncpus; ++i)
  21. on_cpu(i, ipi_test, (void *)(long)i);
  22. report("IPI to each CPU", nipis == ncpus);
  23. return report_summary();
  24. }