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

why lines 46 and 59 can't be relaxed in treiber stack #407

Closed
hydium opened this issue Oct 19, 2019 · 0 comments
Closed

why lines 46 and 59 can't be relaxed in treiber stack #407

hydium opened this issue Oct 19, 2019 · 0 comments

Comments

@hydium
Copy link

hydium commented Oct 19, 2019

Thread 1 Thread 2
pub fn push(&self, t: T) {
    let mut n = Owned::new(Node {
        data: ManuallyDrop::new(t),
        next: Atomic::null(),
    });

    let guard = epoch::pin();

    loop {
        let head = self.head.load(Relaxed, &guard);
        

        match self.head.compare_and_set(head, n, Release, &guard) {  <- A
        
        



        n.next.store(head, Relaxed); //<- if A or B are relaxed this operation can be here
                                        //it was before the compare_and_set originally
            Ok(_) => break,
            Err(e) => n = e.new,
        }
    }
}




pub fn pop(&self) -> Option<T> {
    let guard = epoch::pin();
    loop {
        let head = self.head.load(Acquire, &guard); //<- B, if this load is relaxed 
        //this head has a null next pointer because the pointer is set later
@hydium hydium closed this as completed Oct 19, 2019
@kyeongmincho kyeongmincho transferred this issue from kaist-cp/helpdesk Oct 14, 2021
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

1 participant