> Oh! SMP_PAUSE actually jumps here! I would *not* expect that, when I
> read code like this:
>
        > SMP_PAUSE(active);
        > foo();
        > bar(42);
        > SMP_RESUME();
>
> Something like the following would be a lot clearer for me:
>
        > if (mhartid() == active) {
                > foo();
> bar(42);
        > }
> 
> Or maybe:
>
        > if (running_on_hart(active)) { ... }
>
> But note that this lacks the barriers/locking that your code has.
>
> Jonathan Neuschäfer


```
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
-- 
coreboot mailing list: [email protected]
https://mail.coreboot.org/mailman/listinfo/coreboot

Reply via email to