On-the-Fly Garbage Collection: An Exercise in Cooperation
Edsget W. Dijkstra, Leslie Lamport, A.J. Martin and E.F.M. Steffens Communications of the ACM, 1978 Presented by Almog Benin 25/5/2014
On-the-Fly Garbage Collection: An Exercise in Cooperation Edsget W. - - PowerPoint PPT Presentation
On-the-Fly Garbage Collection: An Exercise in Cooperation Edsget W. Dijkstra, Leslie Lamport, A.J. Martin and E.F.M. Steffens Communications of the ACM, 1978 Presented by Almog Benin 25/5/2014 Outline of talk Introduction Problem
Edsget W. Dijkstra, Leslie Lamport, A.J. Martin and E.F.M. Steffens Communications of the ACM, 1978 Presented by Almog Benin 25/5/2014
Root: Free list:
Root: Free list:
Root: Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root: Free list:
Root: Free list:
Root: Free list:
1: Redirects R->R. 2: Redirects R->NR. 3: Add R->R. 4: Add R->NR. 5:delete
Root: Free list:
1: Redirects R->R. 2: Redirects R->NR. 3: Add R->R. 4: Add R->NR. 5:delete
Root: Free list:
NIL 1: Redirects R->R. 2: Redirects R->NR. 3: Add R->R. 4: Add R->NR. 5:delete
– Action type 2 can be translated to two actions
Root: Free list:
NIL
1: Redirects R->R. 2: Redirects R->NR. 3: Add R->R. 4: Add R->NR. 5:delete
– Action type 2 can be translated to two actions
Root: Free list:
NIL
1: Redirects R->R. 2: Redirects R->NR. 3: Add R->R. 4: Add R->NR. 5:delete
– Action type 2 can be translated to two actions
Root: Free list:
NIL
1: Redirects R->R. 2: Redirects R->NR. 3: Add R->R. 4: Add R->NR. 5:delete
already reachable one” (Action type 1)
list an clear the marking from all nodes”
– If the node is white, make it gray. – Otherwise (gray\black), leave it unchanged.
– <Redirect an outgoing edge
towards an already reachable one, and shade the new target>
Root: Free list:
– If the node is white, make it gray. – Otherwise (gray\black), leave it unchanged.
– <Redirect an outgoing edge of a reachable node towards an already reachable one, and shade the new target>
Root: Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝑙 > 0
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝑙 ← 𝑙 − 1
4. 𝑗 ← 𝑗 + 1 %𝑁
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝑙 > 0
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝑙 ← 𝑙 − 1
4. 𝑗 ← 𝑗 + 1 %𝑁
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝑙 > 0
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝑙 ← 𝑙 − 1
4. 𝑗 ← 𝑗 + 1 %𝑁
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Mutator interleaved! Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
𝑁 is the nodes count in the graph
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝑗 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝒋 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝑗 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝑗 white>
4. 𝑗 + +
Root:
Free list:
Mutator interleaved!
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝒋 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝑗 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝒋 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝑗 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝒋 white>
4. 𝑗 + +
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝑙 > 0
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝑙 ← 𝑙 − 1
4. 𝑗 ← 𝑗 + 1 %𝑁
Green simple atomic operations. We will try to break the red.
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝑙 > 0
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝑙 ← 𝑙 − 1
4. 𝑗 ← 𝑗 + 1 %𝑁
Green simple atomic operations. We will try to break the red.
Root:
Free list:
1. Shade all roots. 2. 𝑗 ← 0 3. 𝑙 ← 𝑁 4. While 𝒍 > 𝟏
1. < 𝒅 ←color of node #𝒋> 2. If 𝒅 ==Gray then
1. “C1”: <Shade the successors
black>
3. Else
1. 𝒍 ← 𝒍 − 𝟐
4. 𝒋 ← 𝒋 + 𝟐 %𝑵
Green simple atomic operations. We will try to break the red.
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝑗 white>
4. 𝑗 + +
Root:
Free list:
1. < 𝑑 ←color of node #𝑗> 2. If 𝑑 ==WHITE then
1. <Append node #𝑗 to the free list>
3. Else if 𝑑 == BLACK then
1. <make node #𝑗 white>
4. 𝑗 + +
Root:
Free list:
color.
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Free list:
Root:
Mutator interleaved! Free list:
Root:
Mutator interleaved! Free list:
Root: Free list:
Root: Free list:
Root: Free list:
Root: Free list:
Root: Free list:
– C1.1: <m1 := number of the left-hand successor of node #i> – C1.2: <shade node #M1>
– C1.3: <m2:= number of the right-hand successor of node #i> – C1.4: <shade node #M2>
Root:
Free list:
– C1.1: <m1 := number of the left-hand successor of node #i> – C1.2: <shade node #M1>
– C1.3: <m2:= number of the right-hand successor of node #i> – C1.4: <shade node #M2>
Root:
Free list:
– C1.1: <m1 := number of the left-hand successor of node #i> – C1.2: <shade node #M1>
– C1.3: <m2:= number of the right-hand successor of node #i> – C1.4: <shade node #M2>
Root:
Free list:
– C1.1: <m1 := number of the left-hand successor of node #i> – C1.2: <shade node #M1>
– C1.3: <m2:= number of the right-hand successor of node #i> – C1.4: <shade node #M2>
Root:
Free list:
Root:
Free list:
Root:
Free list:
C-edges