Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/smpcall/smpcall1.c

    r1b20da0 ra35b458  
    6666        size_t *pcall_cnt = (size_t*)p;
    6767        smp_call_t call_info[MAX_CPUS];
    68        
     68
    6969        unsigned int cpu_count = min(config.cpu_active, MAX_CPUS);
    70        
     70
    7171        for (int iter = 0; iter < ITERATIONS; ++iter) {
    7272                /* Synchronous version. */
     
    7979                        smp_call(cpu_id, inc, pcall_cnt);
    8080                }
    81                
     81
    8282                /*
    8383                 * Async calls run in parallel on different cpus, so passing the
     
    8585                 */
    8686                size_t local_cnt[MAX_CPUS] = {0};
    87                
     87
    8888                /* Now start asynchronous calls. */
    8989                for (unsigned cpu_id = 0; cpu_id < cpu_count; ++cpu_id) {
    9090                        smp_call_async(cpu_id, inc, &local_cnt[cpu_id], &call_info[cpu_id]);
    9191                }
    92                
     92
    9393                /* And wait for all async calls to complete. */
    9494                for (unsigned cpu_id = 0; cpu_id < cpu_count; ++cpu_id) {
     
    112112        size_t call_cnt[MAX_CPUS] = {0};
    113113        thread_t *thread[MAX_CPUS] = { NULL };
    114        
     114
    115115        unsigned int cpu_count = min(config.cpu_active, MAX_CPUS);
    116116        size_t running_thread_cnt = 0;
    117117
    118118        TPRINTF("Spawning threads on %u cpus.\n", cpu_count);
    119        
     119
    120120        /* Create a wired thread on each cpu. */
    121121        for (unsigned int id = 0; id < cpu_count; ++id) {
    122122                thread[id] = thread_create(test_thread, &call_cnt[id], TASK,
    123123                        THREAD_FLAG_NONE, "smp-call-test");
    124                
     124
    125125                if (thread[id]) {
    126126                        thread_wire(thread[id], &cpus[id]);
     
    133133        size_t exp_calls = calc_exp_calls(running_thread_cnt);
    134134        size_t exp_calls_sum = exp_calls * cpu_count;
    135        
     135
    136136        TPRINTF("Running %zu wired threads. Expecting %zu calls. Be patient.\n",
    137137                running_thread_cnt, exp_calls_sum);
     
    142142                }
    143143        }
    144        
     144
    145145        /* Wait for threads to complete. */
    146146        for (unsigned int i = 0; i < cpu_count; ++i) {
     
    152152
    153153        TPRINTF("Threads finished. Checking number of smp_call()s.\n");
    154        
     154
    155155        bool ok = true;
    156156        size_t calls_sum = 0;
    157        
     157
    158158        for (size_t i = 0; i < cpu_count; ++i) {
    159159                if (thread[i] != NULL) {
     
    164164                        }
    165165                }
    166                
     166
    167167                calls_sum += call_cnt[i];
    168168        }
    169        
     169
    170170        if (calls_sum != exp_calls_sum) {
    171171                TPRINTF("Error: total acknowledged sum: %zu instead of %zu.\n",
    172172                        calls_sum, exp_calls_sum);
    173                
     173
    174174                ok = false;
    175175        }
    176        
     176
    177177        if (ok) {
    178178                TPRINTF("Success: number of received smp_calls is as expected (%zu).\n",
     
    181181        } else
    182182                return "Failed: incorrect acknowledged smp_calls.\n";
    183        
     183
    184184}
Note: See TracChangeset for help on using the changeset viewer.