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

Potential unprotected critical zone? #4

Open
abbychau opened this issue Jun 23, 2024 · 2 comments
Open

Potential unprotected critical zone? #4

abbychau opened this issue Jun 23, 2024 · 2 comments

Comments

@abbychau
Copy link

Wanna know if it is an unprotected critical zone between 121 and 122

if atomic.LoadUint64(&holder.readWrite) == 0 {

@hedzr
Copy link
Owner

hedzr commented Jun 23, 2024

the ever original idea is:

cas holder.readweite from 0 to 2 must not be failed, logically. so, line 122 would never get in control.
line 122-126 is just a defensive block. it could be remove safely.

if it really reached, the enqueue or dequeue would be failure.

@abbychau
Copy link
Author

abbychau commented Jun 24, 2024

120-123 looks like a potential spinlock to me, but 122 looks like getting away from the spin. so i asked why 121 and 122 works like this.
Kind of unclear to me about the whole retry block ^^; Could you give a bit explanation?

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