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

[HW 6] program stopped while running stack_queue #789

Closed
greenhestu opened this issue Dec 19, 2022 · 3 comments
Closed

[HW 6] program stopped while running stack_queue #789

greenhestu opened this issue Dec 19, 2022 · 3 comments
Assignees
Labels
homework - hazard_pointer hazard_pointer/{mod,hazard,retire}.rs question Further information is requested

Comments

@greenhestu
Copy link

fn stack_queue() {
    const THREADS: usize = 8;
    const ITER: usize = 1024 * 16;

    let stack = Stack::default();
    let queue = Queue::default();
    scope(|s| {
        for _ in 0..THREADS {
            s.spawn(|| {
                for i in 0..ITER {
                    stack.push(i);
                    queue.push(i);
                    stack.try_pop();
                    queue.try_pop();
                    collect();
                    if i % 1000 == 0 {
                        println!("{:?}, {:?} is finished", thread::current().id(), i);
                    }
                }
                println!("died");
            });
        }
    });
    assert!(stack.try_pop().is_none());
}
running 1 test
ThreadId(3), 0 is finished
ThreadId(4), 0 is finished
ThreadId(5), 0 is finished
ThreadId(6), 0 is finished
ThreadId(9), 0 is finished
ThreadId(10), 0 is finished
ThreadId(8), 0 is finished
ThreadId(7), 0 is finished
ThreadId(7), 1000 is finished
ThreadId(4), 1000 is finished
ThreadId(9), 1000 is finished
ThreadId(9), 2000 is finished
ThreadId(9), 3000 is finished
ThreadId(9), 4000 is finished
ThreadId(9), 5000 is finished
ThreadId(9), 6000 is finished
ThreadId(9), 7000 is finished
ThreadId(9), 8000 is finished
ThreadId(9), 9000 is finished
ThreadId(9), 10000 is finished
ThreadId(9), 11000 is finished
ThreadId(9), 12000 is finished
ThreadId(9), 13000 is finished
ThreadId(9), 14000 is finished
ThreadId(9), 15000 is finished
ThreadId(9), 16000 is finished
died

Hi,
I have a problem that stack_queue test is not end
I put println! in stack_queue and the result is above

To figure out the reason for stopping, I also put println! in the loop of my code
but after printing "died" it doesn't print anything

Can you give me some hints to solve this problem?

@greenhestu greenhestu added the question Further information is requested label Dec 19, 2022
@Lee-Janggun
Copy link
Member

Does #787 (comment) help?

@greenhestu
Copy link
Author

greenhestu commented Dec 19, 2022

Thank you for your comment

I put println in Drop for Retireset
the program successfully exits the loop..

@greenhestu
Copy link
Author

The cause of the problem was validate
There was an infinite loop in protect

@Lee-Janggun Lee-Janggun added the homework - hazard_pointer hazard_pointer/{mod,hazard,retire}.rs label Dec 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
homework - hazard_pointer hazard_pointer/{mod,hazard,retire}.rs question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants