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

[Question] HW7 Dropping the Hazard Bag #965

Closed
thekioskman opened this issue Jun 16, 2024 · 3 comments
Closed

[Question] HW7 Dropping the Hazard Bag #965

thekioskman opened this issue Jun 16, 2024 · 3 comments
Assignees
Labels
homework - hazard_pointer hazard_pointer/{mod,hazard,retire}.rs question Further information is requested

Comments

@thekioskman
Copy link

From my understanding to drop the hazard bag we use the atomic pointer at the start of the list and perform a CAS operation with the next node. But in order to get access to the next node, we have to dereference the head node. But in between the instructions of our head.load(), deref head to get next pointer and CAS. The head pointer could already be free'd, and then we would be trying to dereference a free'd pointer.

I can't think of any way to get around this. Is there anything I am missing?

@thekioskman thekioskman added the question Further information is requested label Jun 16, 2024
@kingdoctor123
Copy link
Member

As written in the comment, each slot never gets deallocated until the deallocation of HazardBag. So you don't need to worry about that situation.

@kingdoctor123 kingdoctor123 added the homework - hazard_pointer hazard_pointer/{mod,hazard,retire}.rs label Jun 16, 2024
@thekioskman
Copy link
Author

does that mean we can assume the drop of hazard bag in sequential? Won't multiple threads still call the drop at the same time?

@kingdoctor123
Copy link
Member

Yes. drop requires mutable reference to HazardBag, so there should not be multiple shared references.

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

3 participants