3 ms·
How about a new opcode wait till memory address read equals? That would allow implementing a power efficient spinlock. Oh there is one already. Meet PAUSE: htt
by extropy 7y ago
How about a new opcode wait till memory address read equals? That would allow implementing a power efficient spinlock.
Oh there is one already. Meet PAUSE: https://www.felixcloutier.com/x86/pause https://www.felixcloutier.com/x86/pause
Edit: related post from 2018 https://news.ycombinator.com/item?id=17336853 https://news.ycombinator.com/item?id=17336853
- dbaupp 7y agoThe benchmarked spin-locks are using it, via https://doc.rust-lang.org/std/sync/atomic/fn.spin_loop_hint.html https://doc.rust-lang.org/std/sync/atomic/fn.spin_loop_hint.... Implementation: https://doc.rust-lang.org/src/core/hint.rs.html#64-93 https://doc.rust-lang.org/src/core/hint.rs.html#64-93
- jnordwick 7y agoMONITOR/MWAIT will get you the part where a thread will pause and the cpu can rest until a write on a store on an address range, then the waiting thread is allowed to continue. You can't wait on a specific value though.