3 ms·
Even if the algorithm "works", it does not guard the critical section correctly. The code that is supposed to go between lock() and unlock() may be executed bef
by exDM69 3y ago
Even if the algorithm "works", it does not guard the critical section correctly. The code that is supposed to go between lock() and unlock() may be executed before the lock is acquired or after it is released because CPU is allowed to reorder anything as it wishes in the absence of memory barriers.
Other replies here go further and suggest that the implementation of the algorithm is also broken without barriers, which is probably true as well.