Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not lock-free #1

Closed
WonderfulVoid opened this issue Jan 27, 2019 · 2 comments
Closed

Not lock-free #1

WonderfulVoid opened this issue Jan 27, 2019 · 2 comments

Comments

@WonderfulVoid
Copy link

"Even worse, if a writer holding an index crashes before committing, then the corresponding reader will never succeed in reading one element even if other writer has completed a write operation. This is the reason why WFMPMC is not strict wait-free."
Well, with this behaviour it is not even lock-free as lock-freedom requires system-wide progress (some thread must make progress) even if one thread fails or blocks.

With loops like this: "while((data = getWritable(idx)) == nullptr);", it is actually blocking. Essentially, each individual slot is protected by its own lock (which allows for alternating enqueues and dequeues). Any thread that continues to enqueue/dequeue objects will eventually attempt to access all slots, including any slot that is blocked.

@MengRao
Copy link
Owner

MengRao commented Jan 28, 2019

I didn't say it's lock-free. But it's non-blocking: you can change to "while((data = getWritable(idx)) == nullptr) { do_other_work(); } ".

@MengRao MengRao closed this as completed Jan 28, 2019
@WonderfulVoid
Copy link
Author

You wrote "not strict wait-free" which I interpreted (I confess) as a claim that it then was second best, i.e. lock-free. Wait-free > lock-free > non-blocking > blocking.

With your definition of non-blocking, basically all blocking algorithms can be made non-blocking, just add user-defined callbacks which are invoked when waiting for other threads. I think few people will agree with such a definition.

From Java concurrency in practice (Brian Goetz & co):
"An algorithm is called nonblocking if failure or suspension of any thread cannot cause failure or suspension of another thread".

Take a look at a lock-free ring buffer here:
https://github.com/ARM-software/progress64/blob/master/src/p64_lfring.c
The design has been tested with up to 8 threads but I still need to do some more verification.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants