+ All Categories
Home > Documents > DREADLOCKS: Efficient Deadlock Detection · DREADLOCKS: Efficient Deadlock Detection Maurice...

DREADLOCKS: Efficient Deadlock Detection · DREADLOCKS: Efficient Deadlock Detection Maurice...

Date post: 25-May-2020
Category:
Upload: others
View: 26 times
Download: 0 times
Share this document with a friend
29
DREADLOCKS: Efficient Deadlock Detection Maurice Herlihy Joint work with Eric Koskinen
Transcript

DREADLOCKS: Efficient Deadlock Detection

Maurice HerlihyJoint work with Eric Koskinen

TRANSACT 08 2

Spin-Locks

• Good for short pauses• Multiprocessors• Can be made cache-friendly

TRANSACT 08 3

Deadlock

TRANSACT 08 4

Waits-For Graph

waiting owned

TRANSACT 08 5

Deadlock

waiting owned

TRANSACT 08 6

Dealing with Deadlock

• Avoidance– Not practical if demands not known in

advance• Detection

– Existing algs require complex probing and poking

TRANSACT 08 7

Can Use Timeouts

• Abort if you don’t get lock in time• Plus

– Easy to implement• Minus

– How do you choose timeout?– Is choice robust?

• Different platforms/apps?

TRANSACT 08 8

Dreadlocks

• Fast, incremental deadlock detection• Low overhead• Cache-friendly

• Algorithm …

TRANSACT 08 9

Digest

TRANSACT 08 10

Digest

TRANSACT 08 11

Digest

Uh-oh!

TRANSACT 08 12

Algorithm

• Each thread publishes digest– Initially contains only itself– Always contains itself

• Spins on lock owner’s digest– Propagates changes (union with own)– Aborts if finds itself in owner’s digest

TRANSACT 08 13

public void lock() {while (true) {while ((owner = state.get()) != null) {if (owner.contains(me)) {throw new AbortedException();

} else if (owner.changed()) {myDigest.setUnion(owner, me);

}}if (state.compareAndSet(null, myDigest)) { myDigest.setSingle(me);return;

}}}

T&T&Set Spin Lock

(1)

TRANSACT 08 14

public void lock() {while (true) {while ((owner = state.get()) != null) {if (owner.contains(me)) {throw new AbortedException();

} else if (owner.changed()) {myDigest.setUnion(owner, me);

}}if (state.compareAndSet(null, myDigest)) { myDigest.setSingle(me);return;

}}}

T&T&Set Spin Lock

(1)

Busy lock points to owner digest

TRANSACT 08 15

public void lock() {while (true) {while ((owner = state.get()) != null) {if (owner.contains(me)) {throw new AbortedException();

} else if (owner.changed()) {myDigest.setUnion(owner, me);

}}if (state.compareAndSet(null, myDigest)) { myDigest.setSingle(me);return;

}}}

T&T&Set Spin Lock

(1)

Abort if I’m in owner’s digest

TRANSACT 08 16

public void lock() {while (true) {while ((owner = state.get()) != null) {if (owner.contains(me)) {throw new AbortedException();

} else if (owner.changed()) {myDigest.setUnion(owner, me);

}}if (state.compareAndSet(null, myDigest)) { myDigest.setSingle(me);return;

}}}

T&T&Set Spin Lock

(1)

Back-propagate changes from owner’s digest

TRANSACT 08 17

public void lock() {while (true) {while ((owner = state.get()) != null) {if (owner.contains(me)) {throw new AbortedException();

} else if (owner.changed()) {myDigest.setUnion(owner, me);

}}if (state.compareAndSet(null, myDigest)) { myDigest.setSingle(me);return;

}}}

T&T&Set Spin Lock

(1)

Clear own digest when lock acquired

TRANSACT 08 18

Concurrency

• Digest methods don’t have to be atomic– False positives OK if rare– False negatives OK if transient

• Means we can use multi-word bitmaps

TRANSACT 08 19

Bit Maps

• 32 (or 64) bit array• Good for small sets• Exact membership tests• Manipulated by shifting & masking

TRANSACT 08 20

Bloom Filter

h2h1

TRANSACT 08 21

Testing Membership

member

Yes, maybe…

h2h1

TRANSACT 08 22

No False Negatives

member

No

h2h1

TRANSACT 08 23

False Positivies

member

Yes, maybe

h2h1

TRANSACT 08 24

Experiments• Dreadlock TTAS lock• Used for Abstract Locking in Boosting

• Implemented TTAS lock in C• Built upon Boosting / TL2

• Synthetic benchmark: boosted array

TRANSACT 08 25

TRANSACT 08 26

TRANSACT 08 27

Throughput Small # Threads

TRANSACT 08 28

Throughput Large # Threads

TRANSACT 08 29

No Deadlock No Cry

• Can use locks with reckless abandon• Dreadlocks will detect deadlocks

• So far– Slightly higher overhead


Recommended