Open wks opened 9 years ago
A separate file https://github.com/microvm/microvm-spec/wiki/memory-model-refined is created for drafting this change.
The https://github.com/microvm/microvm-spec/wiki/memory-model-refined page now addresses futex and stack operations.
The current memory model is designed according to the C11/C++11 standard. It involves atomic memory access, locks and threads.
However, there are issues which C11 and C++11 do not address. They are:
wait
implies an atomic load-compare-sleep operation. (See spec)Current ideas:
Futex: (open question) Should
futex_wake
happen before the next instruction after thefutex_wait
that actually wakes up? Probably yes.According to the semantic of RELEASE and ACQUIRE, if OP4 sees the store by OP2, then OP6 must see the store of OP1.
The problem is, if the OP3
futex_wake
is not guaranteed to happen before the waking of OP5futex_wait
, then the next OP4 in the loop may not see the store by OP2 at all, and may go to sleep another time. Then it will be sleeping forever.stack binding/unbinding cannot be atomic. Swap-stack is a combination of two and cannot be atomic, either.
We may require the language implementer to correctly use other synchronisations to make sure racy
swap-stack
operations do not happen.