Previous | Next --- Slide 17 of 30
Back to Lecture Thumbnails
yanzhan2

The reason to use a reclaim pointer is we want the insertion and deletion of node in one thread. If we do not use reclaim, then thread-safe memory allocation is needed. If we delete node in pop operation, then head would possibly delete the node which the tail is pointing to, while it is inserting another node, then it would cause problem.

shabnam

Can this be explained further. Why do we need thread safe memory allocation.

bstan

I believe we need to have thread safe memory allocation so that we are able to allocate and free memory concurrently, which would possibly happen when both the reader and writer try to pop and push (respectively) at the same time.

kprewitt

What problems would develop from trying to allocate and free memory concurrently? The best instincts I have for the issues that would develop is that, if a piece of memory starts to be freed, and that location is marked as free, and then another thread begins to allocate that memory while it is still being freed, then some of that memory could continue to be freed. However, that seems like it would be trivial to avoid. I'm not sure what other issues would be present, at least that also wouldn't be easy to avoid.

jinghuan

We need thread safe memory allocation also to avoid two threads trying to allocate one memory block at the same time.