ABA + Memory Reclamation Flashcards

1
Q

What is the ABA problem?

A

Thread 1 reads a value. thread 2 interrupts and changes it. thread 1 writes original value back again (nodes are recycled)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

ABA problem in the book.

A

Head ends up pointing to a node that is
not in the queue anymore, but has been
added to the free-list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Solution to ABA

A

Each pointer should have a counter. it is unique over the lifetime of the node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What class should we use for the pointer

A

AtomicStampedReference class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens to nodes if we dequeue them

A

we depend on built-in garbage collection to remove them from memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Solution to no garbage collector:

A

each thread has own private free-list of unused queue entries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how does enqueue and dequeue work for the free-lists

A

enq = get node from free list
deq = add removed node to free-list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What should we do if the free-list is empty

A

allocate new node through dynamic memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Problem with free list?

A

when nodes are recycled = ABA problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly