简体   繁体   中英

Can the hardware fetch&add instruction guarantee wait-free execution?

So, if multiple processes execute FAA, is there any guarantee that this FAA instruction will be executed in a wait-free manner? What if processes that finish executing this instruction do not stop there but repeatedly try to execute it?

An algorithm is wait-free if it does not contain retry loops or wait loops. Since fetch_add() never fails (unlike compare_exchange_weak() ), the operation itself is suited for writing wait-free algorithms (as no retry loops are needed). Of course, whether an algorithm using the fetch_add() instruction actually is wait-free depends on the rest of the algorithm. As long as fetch_add() is supported as an instruction on your hardware, it is wait-free. Only if it is not supported, and has to be emulated via CAS loops or LL/CS, it is no longer wait-free, as those are not wait-free.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM