if (running_on_hart(active)) { ... }
Yes, these codes are clearer.
/*
- If your code needs to temporarily block multiple-threads, do this:
SMP_PAUSE(active) // `active` is hartid of working thread
... single-threaded work ...
SMP_RESUME()
... multi-threaded work ...
*/ But sometimes multi-threaded work has to wait for the single-threaded work to complete.
etc: single-threaded work : init ddr controller multi-threaded work : some operations related to memory
It is necessary to wait for the completion of single-threaded work.
Xiang Wang
There is other solution here. ``` #define HART_NUM 5
void smp_sync(unsigned long *cnt) { atomic_add(cnt,1); do { barrier(); }while(*cnt < HART_MAX); }
static unsigned long cnt; if (running_on_hart(active)) { ... } smp_sync(&cnt); ``` This solution must define HART_NUM. I think this solution is not as flexible as SMP_PAUSE/SMP_RESUME. Which solution do you want to use?
Xiang Wang