Changes in kernel/test/smpcall/smpcall1.c [1b20da0:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/smpcall/smpcall1.c
r1b20da0 ra35b458 66 66 size_t *pcall_cnt = (size_t*)p; 67 67 smp_call_t call_info[MAX_CPUS]; 68 68 69 69 unsigned int cpu_count = min(config.cpu_active, MAX_CPUS); 70 70 71 71 for (int iter = 0; iter < ITERATIONS; ++iter) { 72 72 /* Synchronous version. */ … … 79 79 smp_call(cpu_id, inc, pcall_cnt); 80 80 } 81 81 82 82 /* 83 83 * Async calls run in parallel on different cpus, so passing the … … 85 85 */ 86 86 size_t local_cnt[MAX_CPUS] = {0}; 87 87 88 88 /* Now start asynchronous calls. */ 89 89 for (unsigned cpu_id = 0; cpu_id < cpu_count; ++cpu_id) { 90 90 smp_call_async(cpu_id, inc, &local_cnt[cpu_id], &call_info[cpu_id]); 91 91 } 92 92 93 93 /* And wait for all async calls to complete. */ 94 94 for (unsigned cpu_id = 0; cpu_id < cpu_count; ++cpu_id) { … … 112 112 size_t call_cnt[MAX_CPUS] = {0}; 113 113 thread_t *thread[MAX_CPUS] = { NULL }; 114 114 115 115 unsigned int cpu_count = min(config.cpu_active, MAX_CPUS); 116 116 size_t running_thread_cnt = 0; 117 117 118 118 TPRINTF("Spawning threads on %u cpus.\n", cpu_count); 119 119 120 120 /* Create a wired thread on each cpu. */ 121 121 for (unsigned int id = 0; id < cpu_count; ++id) { 122 122 thread[id] = thread_create(test_thread, &call_cnt[id], TASK, 123 123 THREAD_FLAG_NONE, "smp-call-test"); 124 124 125 125 if (thread[id]) { 126 126 thread_wire(thread[id], &cpus[id]); … … 133 133 size_t exp_calls = calc_exp_calls(running_thread_cnt); 134 134 size_t exp_calls_sum = exp_calls * cpu_count; 135 135 136 136 TPRINTF("Running %zu wired threads. Expecting %zu calls. Be patient.\n", 137 137 running_thread_cnt, exp_calls_sum); … … 142 142 } 143 143 } 144 144 145 145 /* Wait for threads to complete. */ 146 146 for (unsigned int i = 0; i < cpu_count; ++i) { … … 152 152 153 153 TPRINTF("Threads finished. Checking number of smp_call()s.\n"); 154 154 155 155 bool ok = true; 156 156 size_t calls_sum = 0; 157 157 158 158 for (size_t i = 0; i < cpu_count; ++i) { 159 159 if (thread[i] != NULL) { … … 164 164 } 165 165 } 166 166 167 167 calls_sum += call_cnt[i]; 168 168 } 169 169 170 170 if (calls_sum != exp_calls_sum) { 171 171 TPRINTF("Error: total acknowledged sum: %zu instead of %zu.\n", 172 172 calls_sum, exp_calls_sum); 173 173 174 174 ok = false; 175 175 } 176 176 177 177 if (ok) { 178 178 TPRINTF("Success: number of received smp_calls is as expected (%zu).\n", … … 181 181 } else 182 182 return "Failed: incorrect acknowledged smp_calls.\n"; 183 183 184 184 }
Note:
See TracChangeset
for help on using the changeset viewer.