- for(int i=0; i<MAX_CORES; i++){
- if(cpu_mask & (1 << i)){
- cpu_count++;
- }
- }
-
- int s = pthread_barrier_init(&barrier, NULL, cpu_count);
- if (s != 0)
- err(1, "pthread_barrier_init");
-
- for(int i=0; i<MAX_CORES; i++){
- if(cpu_mask & (1 << i)){
- cores[i] = i;
- retvals[i] = pthread_create(&threads[i], NULL, test_thread, (void*) &cores[i]);
- }
- }
-
- for(int i=0; i<MAX_CORES; i++){
- if(cpu_mask & (1 << i)){
- pthread_join(threads[i], NULL);
- }
- }
-
+ for (int i = 0; i < MAX_CORES; i++) {
+ if (cpu_mask & (1 << i)) {
+ cpu_count++;
+ }
+ }
+
+ printf("CPU count:%d CPU mask:%#x\n", cpu_count, cpu_mask);
+ int s = pthread_barrier_init(&barrier, NULL, cpu_count);
+ if (s != 0)
+ error(1, s, "pthread_barrier_init");
+
+ for (intptr_t i = 0; i < MAX_CORES; i++) {
+ if (cpu_mask & (1 << i))
+ pthread_create(&threads[i], NULL, test_thread, (void *)i);
+ }
+
+ for (int i = 0; i < MAX_CORES; i++) {
+ if (cpu_mask & (1 << i)) {
+ pthread_join(threads[i], NULL);
+ }
+ }
+