| ▲ | jnwatson an hour ago | ||||||||||||||||||||||||||||||||||||||||||||||
Also, there's no guarantee of progress. The writer can starve the reader forever. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | adrian_b 26 minutes ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
That is always possible, even in any algorithm that claims to be wait-free, if some writer just keeps writing the shared data. All the claims about something being lock-free and/or wait-free depend on a rational behavior of the writers. If any writer acts crazy, progress becomes impossible regardless of what all others do, unless someone kills the rogue thread or process. In practice, the algorithm from TFA is much more likely to guarantee progress than any of the algorithms that are theoretically proven to guarantee progress, because it has an extremely small overhead, while the alternatives are much more complex and they waste a lot of time. Moreover, most wait-free algorithms guarantee progress only for the whole system, in the sense that one random thread will progress, but they do not guarantee anything for a given thread, which may be blocked forever or stuck in an infinite loop, if unlucky. | |||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | danbruc 25 minutes ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||||||||
[...] then the readers will spin forever waiting for the counter to become even again. | |||||||||||||||||||||||||||||||||||||||||||||||