CS-206 Concurrency. Lecture 8 Concurrent. Data structures. a b c d. Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/ remove(c) remove(b)

Size: px
Start display at page:

Download "CS-206 Concurrency. Lecture 8 Concurrent. Data structures. a b c d. Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/ remove(c) remove(b)"

Transcription

1 CS-206 Concurrency Lecture 8 Concurrent a b c d Data structures Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/ remove(b) remove(c) Adapted from slides originally developed by Maurice Herlihy and Nir Shavit from the Art of Multiprocessor Programming, and Babak Falsafi EPFL Copyright 2015 EPFL CS-206 Spring 2015 Lec.8-1

2 Where are We? Lecture & Lab M T W T F 16-Feb 17-Feb 18-Feb 19-Feb 20-Feb 23-Feb 24-Feb 25-Feb 26-Feb 27-Feb 2-Mar 3-Mar 4-Mar 5-Mar 6-Mar 9-Mar 10-Mar 11-Mar 12-Mar 13-Mar 16-Mar 17-Mar 18-Mar 19-Mar 20-Mar 23-Mar 24-Mar 25-Mar 26-Mar 27-Mar 30-Mar 31-Mar 1-Apr 2-Apr 3-Apr 6-Apr 7-Apr 8-Apr 9-Apr 10-Apr 13-Apr 14-Apr 15-Apr 16-Apr 17-Apr 20-Apr 21-Apr 22-Apr 23-Apr 24-Apr 27-Apr 28-Apr 29-Apr 30-Apr 1-May 4-May 5-May 6-May 7-May 8-May 11-May 12-May 13-May 14-May 15-May 18-May 19-May 20-May 21-May 22-May 25-May 26-May 27-May 28-May 29-May u Concurrent data structures w Coarse-grained locking w Fine-grained locking w Lock-free data structures u Examples w Linked lists u Next week w Higher-level data structures EPFL CS-206 Spring 2015 Lec.8-2

3 Contention u When many threads compete for a lock u Prevents efficient multithreaded execution w Threads spend more time waiting for lock than doing work u Real problem in multiprocessor programming EPFL CS-206 Spring 2015 Lec.8-3

4 Today: Concurrent Objects u Adding threads should not lower throughput w Contention effects u Should increase throughput w Not possible if inherently sequential w Surprising things are parallelizable EPFL CS-206 Spring 2015 Lec.8-4

5 Coarse-Grained Synchronization u Each method locks the object w Avoid contention using queue locks w Easy to reason about w In simple cases u Example w Solaris (Oracle s OS) first version had a single lock w Every time there was an OS access, one thread could get in w What is wrong with this picture? EPFL CS-206 Spring 2015 Lec.8-5

6 Coarse-Grained Synchronization u Sequential bottleneck w Threads stand in line u Adding more threads w Does not improve throughput w Struggle to keep it from getting worse u So why even use a multiprocessor? w Well, some apps are inherently parallel EPFL CS-206 Spring 2015 Lec.8-6

7 Fine-Grained Synchronization u Instead of using a single lock u Split object into w Independently-synchronized components u Methods conflict when they access w The same component w At the same time EPFL CS-206 Spring 2015 Lec.8-7

8 Example with Linked List u Illustrate these patterns u Using a list-based Set w Common application w Building block for other apps EPFL CS-206 Spring 2015 Lec.8-8

9 List-Based Sets public interface Set<T> { public boolean add(t x); public boolean remove(t x); public boolean contains(t x); } EPFL CS-206 Spring 2015 Lec.8-9

10 List-Based Sets public interface Set<T> { public boolean add(t x); public boolean remove(t x); public boolean contains(t x); } Add item to set EPFL CS-206 Spring 2015 Lec.8-10

11 List-Based Sets public interface Set<T> { public boolean add(t x); public boolean remove(t x); public boolean contains(t x); } Remove item from set EPFL CS-206 Spring 2015 Lec.8-11

12 List-Based Sets public interface Set<T> { public boolean add(t x); public boolean remove(t x); public boolean contains(t x); } Is item in set? EPFL CS-206 Spring 2015 Lec.8-12

13 List Node public class Node { public T item; public int key; public Node next; } EPFL CS-206 Spring 2015 Lec.8-13

14 List Node public class Node { public T item; public int key; public Node next; } item of interest EPFL CS-206 Spring 2015 Lec.8-14

15 List Node public class Node { public T item; public int key; public Node next; } Usually hash code EPFL CS-206 Spring 2015 Lec.8-15

16 List Node public class Node { public T item; public int key; public Node next; } Reference to next node EPFL CS-206 Spring 2015 Lec.8-16

17 Reasoning about Concurrent Objects u Invariant w Property that always holds u Why do we care about invariants? w Invariant is true when object is created w Invariant truth is preserved by each method w Each step of each method EPFL CS-206 Spring 2015 Lec.8-17

18 Specifically u Invariants preserved by w add() w remove() w contains() u Example invariants to preserve for linked lists w Tail reachable from head w Sorted w No duplicates EPFL CS-206 Spring 2015 Lec.8-18

19 Sequential List Based Set add() a c d remove() a b c EPFL CS-206 Spring 2015 Lec.8-19

20 Sequential List Based Set add() a c d remove() b a b c EPFL CS-206 Spring 2015 Lec.8-20

21 Coarse-Grained Locking a b d EPFL CS-206 Spring 2015 Lec.8-21

22 Coarse-Grained Locking a b d c EPFL CS-206 Spring 2015 Lec.8-22

23 Coarse-Grained Locking a b d honk! honk! c Simple but hotspot + bottleneck EPFL CS-206 Spring 2015 Lec.8-23

24 Coarse-Grained Locking u Easy, same as synchronized methods w One lock to rule them all u Simple, clearly correct w Deserves respect! u Works poorly with contention w Queue locks help w But bottleneck still an issue EPFL CS-206 Spring 2015 Lec.8-24

25 Fine-grained Locking u Requires careful thought w Do not meddle in the affairs of wizards, for they are subtle and quick to anger u Split object into pieces w Each piece has own lock w Methods that work on disjoint pieces need not exclude each other EPFL CS-206 Spring 2015 Lec.8-25

26 Hand-over-Hand locking a b c EPFL CS-206 Spring 2015 Lec.8-26

27 Hand-over-Hand locking a b c EPFL CS-206 Spring 2015 Lec.8-27

28 Hand-over-Hand locking a b c EPFL CS-206 Spring 2015 Lec.8-28

29 Hand-over-Hand locking a b c EPFL CS-206 Spring 2015 Lec.8-29

30 Hand-over-Hand locking a b c EPFL CS-206 Spring 2015 Lec.8-30

31 Removing a Node a b c d remove(b) EPFL CS-206 Spring 2015 Lec.8-31

32 Removing a Node a b c d remove(b) EPFL CS-206 Spring 2015 Lec.8-32

33 Removing a Node a b c d remove(b) EPFL CS-206 Spring 2015 Lec.8-33

34 Removing a Node a b c d remove(b) EPFL CS-206 Spring 2015 Lec.8-34

35 Removing a Node a b c d remove(b) EPFL CS-206 Spring 2015 Lec.8-35

36 Removing a Node a c d remove(b) Why hold 2 locks? EPFL CS-206 Spring 2015 Lec.8-36

37 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-37

38 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-38

39 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-39

40 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-40

41 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-41

42 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-42

43 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-43

44 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-44

45 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-45

46 Concurrent Removes a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-46

47 Uh, Oh a c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-47

48 Uh, Oh Bad news, c not removed a c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-48

49 Problem a b c u To delete node c w Swing node b s next field to d a b c u Problem is, w Someone deleting b concurrently could direct a pointer to c EPFL CS-206 Spring 2015 Lec.8-49

50 Insight u If a node is locked w No one can delete node s successor u If a thread locks w Node to be deleted w And its predecessor w Then it works EPFL CS-206 Spring 2015 Lec.8-50

51 Hand-Over-Hand Again a b c d remove(b) EPFL CS-206 Spring 2015 Lec.8-51

52 Hand-Over-Hand Again a b c d remove(b) EPFL CS-206 Spring 2015 Lec.8-52

53 Hand-Over-Hand Again a b c d remove(b) EPFL CS-206 Spring 2015 Lec.8-53

54 Hand-Over-Hand Again a b c d remove(b) Found it! EPFL CS-206 Spring 2015 Lec.8-54

55 Hand-Over-Hand Again a b c d remove(b) Found it! EPFL CS-206 Spring 2015 Lec.8-55

56 Hand-Over-Hand Again a c d remove(b) EPFL CS-206 Spring 2015 Lec.8-56

57 Removing a Node a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-57

58 Removing a Node a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-58

59 Removing a Node a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-59

60 Removing a Node a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-60

61 Removing a Node a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-61

62 Removing a Node a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-62

63 Removing a Node a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-63

64 Removing a Node a b c d remove(b) remove(c) EPFL CS-206 Spring 2015 Lec.8-64

65 Removing a Node a b c d Must acquire lock for b remove(c) EPFL CS-206 Spring 2015 Lec.8-65

66 Removing a Node a b c d Cannot acquire lock for b remove(c) EPFL CS-206 Spring 2015 Lec.8-66

67 Removing a Node a b c d Wait! remove(c) EPFL CS-206 Spring 2015 Lec.8-67

68 Removing a Node a b d Proceed to remove(b) EPFL CS-206 Spring 2015 Lec.8-68

69 Removing a Node a b d remove(b) EPFL CS-206 Spring 2015 Lec.8-69

70 Removing a Node a b d remove(b) EPFL CS-206 Spring 2015 Lec.8-70

71 Removing a Node a d remove(b) EPFL CS-206 Spring 2015 Lec.8-71

72 Removing a Node a d EPFL CS-206 Spring 2015 Lec.8-72

73 Remove method public boolean remove(item item) { int key = item.hashcode(); Node pred, curr; boolean foundnode = false; try { } finally { curr.unlock(); pred.unlock(); } return foundnode; } EPFL CS-206 Spring 2015 Lec.8-73

74 Remove method public boolean remove(item item) { int key = item.hashcode(); Node pred, curr; boolean foundnode = false; try { } finally { curr.unlock(); pred.unlock(); } return foundnode; } Key used to order node EPFL CS-206 Spring 2015 Lec.8-74

75 Remove method public boolean remove(item item) { int key = item.hashcode(); Node pred, curr; boolean foundnode = false; try { } finally { curr.unlock(); pred.unlock(); } return foundnode; } Predecessor and current nodes EPFL CS-206 Spring 2015 Lec.8-75

76 Remove method public boolean remove(item item) { int key = item.hashcode(); Node pred, curr; boolean foundnode = false; try { } finally { curr.unlock(); pred.unlock(); } return foundnode; } Node search EPFL CS-206 Spring 2015 Lec.8-76

77 Remove method public boolean remove(item item) { int key = item.hashcode(); Node pred, curr; boolean foundnode = false; try { } finally { curr.unlock(); pred.unlock(); } return foundnode; } Make sure locks released EPFL CS-206 Spring 2015 Lec.8-77

78 Remove method public boolean remove(item item) { int key = item.hashcode(); Node pred, curr; boolean foundnode = false; try { } finally { curr.unlock(); pred.unlock(); } return foundnode; } Everything else EPFL CS-206 Spring 2015 Lec.8-78

79 Remove method try { pred = this.head; pred.lock(); curr = pred.next; curr.lock(); } finally { } EPFL CS-206 Spring 2015 Lec.8-79

80 Remove method try { pred = this.head; pred.lock(); curr = pred.next; curr.lock(); } finally { } lock pred == head EPFL CS-206 Spring 2015 Lec.8-80

81 Remove method try { pred = this.head; pred.lock(); curr = pred.next; curr.lock(); } finally { } Lock current EPFL CS-206 Spring 2015 Lec.8-81

82 Remove method try { pred = this.head; pred.lock(); curr = pred.next; curr.lock(); } finally { } Traversing list EPFL CS-206 Spring 2015 Lec.8-82

83 Remove: searching while (curr.key <= key) { if (item == curr.item) { pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } EPFL CS-206 Spring 2015 Lec.8-83

84 Remove: searching while (curr.key <= key) { if (item == curr.item) { pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } Search key range EPFL CS-206 Spring 2015 Lec.8-84

85 Remove: searching while (curr.key <= key) { if (item == curr.item) { pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } At start of each loop: curr and pred locked EPFL CS-206 Spring 2015 Lec.8-85

86 Remove: searching while (curr.key <= key) { if (item == curr.item) { pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } foundnode = false; If item found, remove node EPFL CS-206 Spring 2015 Lec.8-86

87 Remove: searching while (curr.key <= key) { if (item == curr.item) { pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } foundnode = false; If node found, remove it EPFL CS-206 Spring 2015 Lec.8-87

88 Remove: searching while (curr.key <= key) { if (item == curr.item) { pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } Unlock predecessor EPFL CS-206 Spring 2015 Lec.8-88

89 Remove: searching Only one node locked! while (curr.key <= key) { if (item == curr.item) { pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } EPFL CS-206 Spring 2015 Lec.8-89

90 Remove: searching while (curr.key <= key) { if (item == curr.item) { demote current pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } EPFL CS-206 Spring 2015 Lec.8-90

91 Remove: searching while (curr.key <= key) { if (item == curr.item) { pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } Find and lock new current EPFL CS-206 Spring 2015 Lec.8-91

92 Remove: searching while (curr.key <= key) { if Lock (item invariant == curr.item) restored { pred.next = curr.next; foundnode = true; break; } pred.unlock(); pred = curr; curr = curr.next; curr.lock(); } EPFL CS-206 Spring 2015 Lec.8-92

93 Why does this work? u To remove node e w Must lock e w Must lock e s predecessor u Therefore, if you lock a node w It can t be removed w And neither can its successor EPFL CS-206 Spring 2015 Lec.8-93

94 Adding Nodes u To add node e w Must lock predecessor w Must lock successor u Add/remove must acquire locks in the same order w What happens in the order is compromised? w E.g., remove code lock predecessor first, add successor first EPFL CS-206 Spring 2015 Lec.8-94

95 Properties to prove for add/remove u Does safetyness hold? u Does the liveness property hold? u Are the invariants maintained? EPFL CS-206 Spring 2015 Lec.8-95

96 Drawbacks u Better than coarse-grained lock w Threads can traverse in parallel u Still not ideal w Long chain of acquire/release w Inefficient EPFL CS-206 Spring 2015 Lec.8-96

97 Traffic Jam u Any concurrent data structure based on mutual exclusion has a weakness u If one thread w Enters critical section w And eats the big muffin w Cache miss, page fault, descheduled w Everyone else using that lock is stuck! w Need to trust the scheduler. EPFL CS-206 Spring 2015 Lec.8-97

98 Other patterns: Optimistic Synchronization u Search without locking u If you find it, lock an check w Ok à we are done w Opps à start over u Evaluation w Usually cheaper than locking w Mistakes are expensive EPFL CS-206 Spring 2015 Lec.8-98

99 Optimistic: Traverse without Locking a b d e add(c) Aha! EPFL CS-206 Spring 2015 Lec.8-99

100 Optimistic: Lock and Load a b d e add(c) EPFL CS-206 Spring 2015 Lec.8-100

101 Optimistic: Lock and Load c a b d e add(c) EPFL CS-206 Spring 2015 Lec.8-101

102 What could go wrong? a b d e add(c) Aha! EPFL CS-206 Spring 2015 Lec.8-102

103 What could go wrong? a b d e add(c) EPFL CS-206 Spring 2015 Lec.8-103

104 What could go wrong? a b d e remove(b) EPFL CS-206 Spring 2015 Lec.8-104

105 What could go wrong? a b d e remove(b) EPFL CS-206 Spring 2015 Lec.8-105

106 What could go wrong? a b d e add(c) EPFL CS-206 Spring 2015 Lec.8-106

107 What could go wrong? c a b d e add(c) EPFL CS-206 Spring 2015 Lec.8-107

108 What could go wrong? a d e add(c) Uh-oh EPFL CS-206 Spring 2015 Lec.8-108

109 Check after lock u By traversing optimistically, we give up any guarantees we had about the list during traversal u The node we locked might have just been removed u Need to check the pointers to it EPFL CS-206 Spring 2015 Lec.8-109

110 What Else Could Go Wrong? a b d e add(c) Aha! EPFL CS-206 Spring 2015 Lec.8-110

111 What Else Could Go Wrong? a b d e add(c) add(b ) EPFL CS-206 Spring 2015 Lec.8-111

112 What Else Could Go Wrong? a b d e add(c) b add(b ) EPFL CS-206 Spring 2015 Lec.8-112

113 What Else Could Go Wrong? a b d e b add(c) EPFL CS-206 Spring 2015 Lec.8-113

114 What Else Could Go Wrong? c a b d e add(c) EPFL CS-206 Spring 2015 Lec.8-114

115 Check after lock u By traversing optimistically, we give up any guarantees we had about the list during traversal u New nodes might just have been added u Need to check the pointers between the locked nodes EPFL CS-206 Spring 2015 Lec.8-115

116 Optimistic Traversal u Traverse optimistically, get the lock and then check if we can move on u Need to check after we get the lock w We know nothing about the items locked w Need to check if they are in the same situation as they were before we locked w After checking, we know that we hold the lock, and thus they cannot suffer further changes EPFL CS-206 Spring 2015 Lec.8-116

117 Other patterns: Lazy Synchronization u Postpone hard work u E.g., break remove into two parts w Logical removal à marks component to be deleted w Physical removal à do what needs to be done EPFL CS-206 Spring 2015 Lec.8-117

118 Reminder: Lock-Free Data Structures u No matter what w Guarantees minimal progress in any execution w i.e. Some thread will always complete a method call w Even if others halt at malicious times w Implies that implementation can t use locks EPFL CS-206 Spring 2015 Lec.8-118

119 Recall: Using atomics u compareandset(expectedvalue,newvalue) method w Compares a variable with an expectedvalue given as input w Sets it to newvalue if comparison is successful w Does everything atomically EPFL CS-206 Spring 2015 Lec.8-119

120 Lock-free Lists u Next logical step w Wait-free contains() w lock-free add() and remove() u How about turning adds/removes into atomics? w Use compareandset() or CAS What could go wrong with only CAS? EPFL CS-206 Spring 2015 Lec.8-120

121 Lock-free Lists a b c 0 e Use CAS to verify pointer is correct Removal Not enough! EPFL CS-206 Spring 2015 Lec.8-121

122 Problem a b c e Removal d Node added EPFL CS-206 Spring 2015 Lec.8-122

123 The Solution: Combine Bit and Pointer Logical Removal = Set Mark Bit a 0 b 0 c 01 e 0 Physical Removal CAS Mark-Bit and Pointer are CASed together (AtomicMarkableReference) d 0 Fail CAS: Node not added after logical Removal EPFL CS-206 Spring 2015 Lec.8-123

124 Solution u Use AtomicMarkableReference u Atomically w Swing reference and w Update flag u Remove in two steps w Set mark bit in next field w Redirect predecessor s pointer EPFL CS-206 Spring 2015 Lec.8-124

125 Marking a Node u AtomicMarkableReference class w Java.util.concurrent.atomic package Reference address F mark bit EPFL CS-206 Spring 2015 Lec.8-125

126 Extracting Reference & Mark Public Object get(boolean[] marked); EPFL CS-206 Spring 2015 Lec.8-126

127 Extracting Reference & Mark Public Object get(boolean[] marked); Returns reference Returns mark at array index 0! (funny use of Java arrays to pass a pointer) EPFL CS-206 Spring 2015 Lec.8-127

128 Extracting Mark Only public boolean ismarked(); Value of mark EPFL CS-206 Spring 2015 Lec.8-128

129 Changing State Public boolean compareandset( Object expectedref, Object updateref, boolean expectedmark, boolean updatemark); EPFL CS-206 Spring 2015 Lec.8-129

130 Changing State If this is the current reference Public boolean compareandset( Object expectedref, Object updateref, boolean expectedmark, boolean updatemark); And this is the current mark EPFL CS-206 Spring 2015 Lec.8-130

131 Changing State then change to this new reference Public boolean compareandset( Object expectedref, Object updateref, boolean expectedmark, boolean updatemark); and this new mark EPFL CS-206 Spring 2015 Lec.8-131

132 Changing State public boolean attemptmark( Object expectedref, boolean updatemark); EPFL CS-206 Spring 2015 Lec.8-132

133 Changing State public boolean attemptmark( Object expectedref, boolean updatemark); If this is the current reference EPFL CS-206 Spring 2015 Lec.8-133

134 Changing State public boolean attemptmark( Object expectedref, boolean updatemark);.. then change to this new mark. EPFL CS-206 Spring 2015 Lec.8-134

135 Removing a Node a b CAS c d remove(c) EPFL CS-206 Spring 2015 Lec.8-135

136 Removing a Node failed a CAS b CAS c d remove(c) remove(b) EPFL CS-206 Spring 2015 Lec.8-136

137 Removing a Node a b c d remove(c) remove(b) EPFL CS-206 Spring 2015 Lec.8-137

138 Removing a Node a d remove(c) remove(b) EPFL CS-206 Spring 2015 Lec.8-138

139 Summary u Coarse-grained locking u Fine-grained locking w Basic synchronization w Optimistic synchronization w Lazy synchronization u Lock-free synchronization EPFL CS-206 Spring 2015 Lec.8-139

CS-206 Concurrency. Lecture 13. Wrap Up. Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/

CS-206 Concurrency. Lecture 13. Wrap Up. Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/ CS-206 Concurrency Lecture 13 Wrap Up Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/ Created by Nooshin Mirzadeh, Georgios Psaropoulos and Babak Falsafi EPFL Copyright 2015 EPFL CS-206 Spring

More information

Safety and Liveness. Thread Synchronization: Too Much Milk. Critical Sections. A Really Cool Theorem

Safety and Liveness. Thread Synchronization: Too Much Milk. Critical Sections. A Really Cool Theorem Safety and Liveness Properties defined over an execution of a program Thread Synchronization: Too Much Milk Safety: nothing bad happens holds in every finite execution prefix Windows never crashes No patient

More information

Technical Report. A safety proof of a lazy concurrent list-based set implementation. Viktor Vafeiadis, Maurice Herlihy, Tony Hoare, Marc Shapiro

Technical Report. A safety proof of a lazy concurrent list-based set implementation. Viktor Vafeiadis, Maurice Herlihy, Tony Hoare, Marc Shapiro Technical Report UCAM-CL-TR-659 ISSN 1476-2986 Number 659 Computer Laboratory A safety proof of a lazy concurrent list-based set implementation Viktor Vafeiadis, Maurice Herlihy, Tony Hoare, Marc Shapiro

More information

Distributed Systems Part II Solution to Exercise Sheet 10

Distributed Systems Part II Solution to Exercise Sheet 10 Distributed Computing HS 2012 Prof. R. Wattenhofer / C. Decker Distributed Systems Part II Solution to Exercise Sheet 10 1 Spin Locks A read-write lock is a lock that allows either multiple processes to

More information

INF 4140: Models of Concurrency Series 3

INF 4140: Models of Concurrency Series 3 Universitetet i Oslo Institutt for Informatikk PMA Olaf Owe, Martin Steffen, Toktam Ramezani INF 4140: Models of Concurrency Høst 2016 Series 3 14. 9. 2016 Topic: Semaphores (Exercises with hints for solution)

More information

Design Patterns and Refactoring

Design Patterns and Refactoring Singleton Oliver Haase HTWG Konstanz 1 / 19 Description I Classification: object based creational pattern Puropse: ensure that a class can be instantiated exactly once provide global access point to single

More information

Real Time Operating Systems

Real Time Operating Systems Real Time Operating ystems Luca Abeni luca.abeni@unitn.it Interacting Tasks Until now, only independent tasks... A job never blocks or suspends A task only blocks on job termination In real world, jobs

More information

Clojure Concurrency Constructs, Part Two. CSCI 5828: Foundations of Software Engineering Lecture 13 10/07/2014

Clojure Concurrency Constructs, Part Two. CSCI 5828: Foundations of Software Engineering Lecture 13 10/07/2014 Clojure Concurrency Constructs, Part Two CSCI 5828: Foundations of Software Engineering Lecture 13 10/07/2014 1 Goals Cover the material presented in Chapter 4, of our concurrency textbook In particular,

More information

1 Lamport s Bakery Algorithm

1 Lamport s Bakery Algorithm Com S 6 Spring Semester 2009 Algorithms for Multiprocessor Synchronization Lecture 3: Tuesday, 27th January 2009 Instructor: Soma Chaudhuri Scribe: Neeraj Khanolkar Lamport s Bakery Algorithm Algorithm

More information

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Consensus. One Reason: Impossibility of Consensus. Let s Consider This

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Consensus. One Reason: Impossibility of Consensus. Let s Consider This Recap: Finger Table Finding a using fingers Distributed Systems onsensus Steve Ko omputer Sciences and Engineering University at Buffalo N102 86 + 2 4 N86 20 + 2 6 N20 2 Let s onsider This

More information

CS-206 Concurrency. Lecture 10. Scheduling & Work Distribution. Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/

CS-206 Concurrency. Lecture 10. Scheduling & Work Distribution. Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/ CS-206 Concurrency Lecture 10 zzz Scheduling & Work Distribution Spring 2015 Prof. Babak Falsafi parsa.epfl.ch/courses/cs206/ Adapted from slides originally developed by Maurice Herlihy and Nir Shavit

More information

Graph-theoretic Problems

Graph-theoretic Problems Graph-theoretic Problems Parallel algorithms for fundamental graph-theoretic problems: We already used a parallelization of dynamic programming to solve the all-pairs-shortest-path problem. Here we are

More information

Real Time Operating Systems

Real Time Operating Systems Real Time Operating ystems hared Resources Luca Abeni Credits: Luigi Palopoli, Giuseppe Lipari, and Marco Di Natale cuola uperiore ant Anna Pisa -Italy Real Time Operating ystems p. 1 Interacting Tasks

More information

CS 6112 (Fall 2011) Foundations of Concurrency

CS 6112 (Fall 2011) Foundations of Concurrency CS 6112 (Fall 2011) Foundations of Concurrency 29 November 2011 Scribe: Jean-Baptiste Jeannin 1 Readings The readings for today were: Eventually Consistent Transactions, by Sebastian Burckhardt, Manuel

More information

Computational Models Lecture 9, Spring 2009

Computational Models Lecture 9, Spring 2009 Slides modified by Benny Chor, based on original slides by Maurice Herlihy, Brown University. p. 1 Computational Models Lecture 9, Spring 2009 Reducibility among languages Mapping reductions More undecidable

More information

CSE 140 Spring 2017: Final Solutions (Total 50 Points)

CSE 140 Spring 2017: Final Solutions (Total 50 Points) CSE 140 Spring 2017: Final Solutions (Total 50 Points) 1. (Boolean Algebra) Prove the following Boolean theorem using Boolean laws only, i.e. no theorem is allowed for the proof. State the name of the

More information

An analogy from Calculus: limits

An analogy from Calculus: limits COMP 250 Fall 2018 35 - big O Nov. 30, 2018 We have seen several algorithms in the course, and we have loosely characterized their runtimes in terms of the size n of the input. We say that the algorithm

More information

TDDB68 Concurrent programming and operating systems. Lecture: CPU Scheduling II

TDDB68 Concurrent programming and operating systems. Lecture: CPU Scheduling II TDDB68 Concurrent programming and operating systems Lecture: CPU Scheduling II Mikael Asplund, Senior Lecturer Real-time Systems Laboratory Department of Computer and Information Science Copyright Notice:

More information

INF Models of concurrency

INF Models of concurrency INF4140 - Models of concurrency Fall 2017 October 17, 2017 Abstract This is the handout version of the slides for the lecture (i.e., it s a rendering of the content of the slides in a way that does not

More information

Latches. October 13, 2003 Latches 1

Latches. October 13, 2003 Latches 1 Latches The second part of CS231 focuses on sequential circuits, where we add memory to the hardware that we ve already seen. Our schedule will be very similar to before: We first show how primitive memory

More information

Technical Report Sequential Proximity

Technical Report Sequential Proximity Technical Report Sequential Proximity Towards Provably Scalable Concurrent Search Algorithms Karolos Antoniadis, Rachid Guerraoui, Julien Stainer, and Vasileios Trigonakis École Polytechnique Fédérale

More information

Computational Complexity. This lecture. Notes. Lecture 02 - Basic Complexity Analysis. Tom Kelsey & Susmit Sarkar. Notes

Computational Complexity. This lecture. Notes. Lecture 02 - Basic Complexity Analysis. Tom Kelsey & Susmit Sarkar. Notes Computational Complexity Lecture 02 - Basic Complexity Analysis Tom Kelsey & Susmit Sarkar School of Computer Science University of St Andrews http://www.cs.st-andrews.ac.uk/~tom/ twk@st-andrews.ac.uk

More information

1 Boolean Algebra Simplification

1 Boolean Algebra Simplification cs281: Computer Organization Lab3 Prelab Our objective in this prelab is to lay the groundwork for simplifying boolean expressions in order to minimize the complexity of the resultant digital logic circuit.

More information

(Refer Slide Time: 1:49)

(Refer Slide Time: 1:49) Analog Electronic Circuits Professor S. C. Dutta Roy Department of Electrical Engineering Indian Institute of Technology Delhi Lecture no 14 Module no 01 Midband analysis of FET Amplifiers (Refer Slide

More information

A Short Introduction to Hoare Logic

A Short Introduction to Hoare Logic A Short Introduction to Hoare Logic Supratik Chakraborty I.I.T. Bombay June 23, 2008 Supratik Chakraborty (I.I.T. Bombay) A Short Introduction to Hoare Logic June 23, 2008 1 / 34 Motivation Assertion checking

More information

Lecture 4: Best, Worst, and Average Case Complexity. Wednesday, 30 Sept 2009

Lecture 4: Best, Worst, and Average Case Complexity. Wednesday, 30 Sept 2009 @? @? @? @? @? @? @? @? @? @ 8 7 8 7 8 7 8 7 8 7 8 7 8 7 8 7 8 7 8 7 0 0 0 0 0 0 0 0 0 0 ' ' ' ' ' ' ' ' ' ' Lecture 4: Best, Worst, and Average Case Complexity CS204/209 : Algorithms (and Scientific Computing)

More information

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February) Algorithms and Data Structures 016 Week 5 solutions (Tues 9th - Fri 1th February) 1. Draw the decision tree (under the assumption of all-distinct inputs) Quicksort for n = 3. answer: (of course you should

More information

Path Testing and Test Coverage. Chapter 9

Path Testing and Test Coverage. Chapter 9 Path Testing and Test Coverage Chapter 9 Structural Testing Also known as glass/white/open box testing Structural testing is based on using specific knowledge of the program source text to define test

More information

Path Testing and Test Coverage. Chapter 9

Path Testing and Test Coverage. Chapter 9 Path Testing and Test Coverage Chapter 9 Structural Testing Also known as glass/white/open box testing Structural testing is based on using specific knowledge of the program source text to define test

More information

Deadlock (2) Dave Eckhardt Brian Railing Roger Dannenberg

Deadlock (2) Dave Eckhardt Brian Railing Roger Dannenberg Deadlock () Dave Eckhardt Brian Railing Roger Dannenberg 1 1-410, S'18 Synchronization P You should really have, today: Drawn pictures of thread stacks (even if not perfect) Figured out where stubs belong,

More information

Lock using Bakery Algorithm

Lock using Bakery Algorithm Lock using Bakery Algorithm Shankar April 16, 2014 Overview Classical mutual exclusion problem given program with critical sections and threads 0..N 1 obtain entry and exit code for each critical section

More information

Quadratic Equations Part I

Quadratic Equations Part I Quadratic Equations Part I Before proceeding with this section we should note that the topic of solving quadratic equations will be covered in two sections. This is done for the benefit of those viewing

More information

N/4 + N/2 + N = 2N 2.

N/4 + N/2 + N = 2N 2. CS61B Summer 2006 Instructor: Erin Korber Lecture 24, 7 Aug. 1 Amortized Analysis For some of the data structures we ve discussed (namely hash tables and splay trees), it was claimed that the average time

More information

Lecture 27: Theory of Computation. Marvin Zhang 08/08/2016

Lecture 27: Theory of Computation. Marvin Zhang 08/08/2016 Lecture 27: Theory of Computation Marvin Zhang 08/08/2016 Announcements Roadmap Introduction Functions Data Mutability Objects This week (Applications), the goals are: To go beyond CS 61A and see examples

More information

Lecture 2: Symbolic Model Checking With SAT

Lecture 2: Symbolic Model Checking With SAT Lecture 2: Symbolic Model Checking With SAT Edmund M. Clarke, Jr. School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 (Joint work over several years with: A. Biere, A. Cimatti, Y.

More information

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm 8 Priority Queues 8 Priority Queues A Priority Queue S is a dynamic set data structure that supports the following operations: S. build(x 1,..., x n ): Creates a data-structure that contains just the elements

More information

CIS 4930/6930: Principles of Cyber-Physical Systems

CIS 4930/6930: Principles of Cyber-Physical Systems CIS 4930/6930: Principles of Cyber-Physical Systems Chapter 11 Scheduling Hao Zheng Department of Computer Science and Engineering University of South Florida H. Zheng (CSE USF) CIS 4930/6930: Principles

More information

Sequential Logic. Handouts: Lecture Slides Spring /27/01. L06 Sequential Logic 1

Sequential Logic. Handouts: Lecture Slides Spring /27/01. L06 Sequential Logic 1 Sequential Logic Handouts: Lecture Slides 6.4 - Spring 2 2/27/ L6 Sequential Logic Roadmap so far Fets & voltages Logic gates Combinational logic circuits Sequential Logic Voltage-based encoding V OL,

More information

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

Chapter 3 Deterministic planning

Chapter 3 Deterministic planning Chapter 3 Deterministic planning In this chapter we describe a number of algorithms for solving the historically most important and most basic type of planning problem. Two rather strong simplifying assumptions

More information

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2018 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

CSE 331 Winter 2018 Reasoning About Code I

CSE 331 Winter 2018 Reasoning About Code I CSE 331 Winter 2018 Reasoning About Code I Notes by Krysta Yousoufian Original lectures by Hal Perkins Additional contributions from Michael Ernst, David Notkin, and Dan Grossman These notes cover most

More information

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park

Insert Sorted List Insert as the Last element (the First element?) Delete Chaining. 2 Slide courtesy of Dr. Sang-Eon Park 1617 Preview Data Structure Review COSC COSC Data Structure Review Linked Lists Stacks Queues Linked Lists Singly Linked List Doubly Linked List Typical Functions s Hash Functions Collision Resolution

More information

Abstractions and Decision Procedures for Effective Software Model Checking

Abstractions and Decision Procedures for Effective Software Model Checking Abstractions and Decision Procedures for Effective Software Model Checking Prof. Natasha Sharygina The University of Lugano, Carnegie Mellon University Microsoft Summer School, Moscow, July 2011 Lecture

More information

Randomized Algorithms

Randomized Algorithms Randomized Algorithms Prof. Tapio Elomaa tapio.elomaa@tut.fi Course Basics A new 4 credit unit course Part of Theoretical Computer Science courses at the Department of Mathematics There will be 4 hours

More information

The Inductive Proof Template

The Inductive Proof Template CS103 Handout 24 Winter 2016 February 5, 2016 Guide to Inductive Proofs Induction gives a new way to prove results about natural numbers and discrete structures like games, puzzles, and graphs. All of

More information

Correctness of Concurrent Programs

Correctness of Concurrent Programs Correctness of Concurrent Programs Trifon Ruskov ruskov@tu-varna.acad.bg Technical University of Varna - Bulgaria Correctness of Concurrent Programs Correctness of concurrent programs needs to be formalized:

More information

Symbolic Logic Outline

Symbolic Logic Outline Symbolic Logic Outline 1. Symbolic Logic Outline 2. What is Logic? 3. How Do We Use Logic? 4. Logical Inferences #1 5. Logical Inferences #2 6. Symbolic Logic #1 7. Symbolic Logic #2 8. What If a Premise

More information

Lecture 4: Stacks and Queues

Lecture 4: Stacks and Queues Reading materials Goodrich, Tamassia, Goldwasser (6th), chapter 6 OpenDSA (https://opendsa-server.cs.vt.edu/odsa/books/everything/html/): chapter 9.8-13 Contents 1 Stacks ADT 2 1.1 Example: CharStack ADT

More information

Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 20 Travelling Salesman Problem

Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 20 Travelling Salesman Problem Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur Lecture - 20 Travelling Salesman Problem Today we are going to discuss the travelling salesman problem.

More information

CS505: Distributed Systems

CS505: Distributed Systems Cristina Nita-Rotaru CS505: Distributed Systems. Required reading for this topic } Michael J. Fischer, Nancy A. Lynch, and Michael S. Paterson for "Impossibility of Distributed with One Faulty Process,

More information

CSCB63 Winter Week 11 Bloom Filters. Anna Bretscher. March 30, / 13

CSCB63 Winter Week 11 Bloom Filters. Anna Bretscher. March 30, / 13 CSCB63 Winter 2019 Week 11 Bloom Filters Anna Bretscher March 30, 2019 1 / 13 Today Bloom Filters Definition Expected Complexity Applications 2 / 13 Bloom Filters (Specification) A bloom filter is a probabilistic

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Digital Logic

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Digital Logic Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Digital Logic Our goal for the next few weeks is to paint a a reasonably complete picture of how we can go from transistor

More information

416 Distributed Systems

416 Distributed Systems 416 Distributed Systems RAID, Feb 26 2018 Thanks to Greg Ganger and Remzi Arapaci-Dusseau for slides Outline Using multiple disks Why have multiple disks? problem and approaches RAID levels and performance

More information

Binary Decision Diagrams and Symbolic Model Checking

Binary Decision Diagrams and Symbolic Model Checking Binary Decision Diagrams and Symbolic Model Checking Randy Bryant Ed Clarke Ken McMillan Allen Emerson CMU CMU Cadence U Texas http://www.cs.cmu.edu/~bryant Binary Decision Diagrams Restricted Form of

More information

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018

CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2018 CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2018 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis

More information

Design of Distributed Systems Melinda Tóth, Zoltán Horváth

Design of Distributed Systems Melinda Tóth, Zoltán Horváth Design of Distributed Systems Melinda Tóth, Zoltán Horváth Design of Distributed Systems Melinda Tóth, Zoltán Horváth Publication date 2014 Copyright 2014 Melinda Tóth, Zoltán Horváth Supported by TÁMOP-412A/1-11/1-2011-0052

More information

Blocking Synchronization: Streams Vijay Saraswat (Dec 10, 2012)

Blocking Synchronization: Streams Vijay Saraswat (Dec 10, 2012) 1 Streams Blocking Synchronization: Streams Vijay Saraswat (Dec 10, 2012) Streams provide a very simple abstraction for determinate parallel computation. The intuition for streams is already present in

More information

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1 CS 70 Discrete Mathematics and Probability Theory Fall 013 Vazirani Note 1 Induction Induction is a basic, powerful and widely used proof technique. It is one of the most common techniques for analyzing

More information

Course Announcements. Bacon is due next Monday. Next lab is about drawing UIs. Today s lecture will help thinking about your DB interface.

Course Announcements. Bacon is due next Monday. Next lab is about drawing UIs. Today s lecture will help thinking about your DB interface. Course Announcements Bacon is due next Monday. Today s lecture will help thinking about your DB interface. Next lab is about drawing UIs. John Jannotti (cs32) ORMs Mar 9, 2017 1 / 24 ORMs John Jannotti

More information

CS280, Spring 2004: Final

CS280, Spring 2004: Final CS280, Spring 2004: Final 1. [4 points] Which of the following relations on {0, 1, 2, 3} is an equivalence relation. (If it is, explain why. If it isn t, explain why not.) Just saying Yes or No with no

More information

Outline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University

Outline Resource Introduction Usage Testing Exercises. Linked Lists COMP SCI / SFWR ENG 2S03. Department of Computing and Software McMaster University COMP SCI / SFWR ENG 2S03 Department of Computing and Software McMaster University Week 10: November 7 - November 11 Outline 1 Resource 2 Introduction Nodes Illustration 3 Usage Accessing and Modifying

More information

CS5314 Randomized Algorithms. Lecture 15: Balls, Bins, Random Graphs (Hashing)

CS5314 Randomized Algorithms. Lecture 15: Balls, Bins, Random Graphs (Hashing) CS5314 Randomized Algorithms Lecture 15: Balls, Bins, Random Graphs (Hashing) 1 Objectives Study various hashing schemes Apply balls-and-bins model to analyze their performances 2 Chain Hashing Suppose

More information

Exam 1. March 12th, CS525 - Midterm Exam Solutions

Exam 1. March 12th, CS525 - Midterm Exam Solutions Name CWID Exam 1 March 12th, 2014 CS525 - Midterm Exam s Please leave this empty! 1 2 3 4 5 Sum Things that you are not allowed to use Personal notes Textbook Printed lecture notes Phone The exam is 90

More information

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 15 Propositional Calculus (PC)

Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 15 Propositional Calculus (PC) Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras Lecture - 15 Propositional Calculus (PC) So, now if you look back, you can see that there are three

More information

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 14

Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 14 CS 70 Discrete Mathematics and Probability Theory Spring 2016 Rao and Walrand Note 14 Introduction One of the key properties of coin flips is independence: if you flip a fair coin ten times and get ten

More information

PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE

PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE Artificial Intelligence, Computational Logic PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE Lecture 4 Metaheuristic Algorithms Sarah Gaggl Dresden, 5th May 2017 Agenda 1 Introduction 2 Constraint

More information

Algebra Exam. Solutions and Grading Guide

Algebra Exam. Solutions and Grading Guide Algebra Exam Solutions and Grading Guide You should use this grading guide to carefully grade your own exam, trying to be as objective as possible about what score the TAs would give your responses. Full

More information

Data Structures and Algorithms Winter Semester

Data Structures and Algorithms Winter Semester Page 0 German University in Cairo December 26, 2015 Media Engineering and Technology Faculty Prof. Dr. Slim Abdennadher Dr. Wael Abouelsadaat Data Structures and Algorithms Winter Semester 2015-2016 Final

More information

CS162 Operating Systems and Systems Programming Lecture 7 Semaphores, Conditional Variables, Deadlocks"

CS162 Operating Systems and Systems Programming Lecture 7 Semaphores, Conditional Variables, Deadlocks CS162 Operating Systems and Systems Programming Lecture 7 Semaphores, Conditional Variables, Deadlocks" September 19, 2012! Ion Stoica! http://inst.eecs.berkeley.edu/~cs162! Recap: Monitors" Monitors represent

More information

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Modern Algebra Prof. Manindra Agrawal Department of Computer Science and Engineering Indian Institute of Technology, Kanpur Lecture 02 Groups: Subgroups and homomorphism (Refer Slide Time: 00:13) We looked

More information

Recent developments in concurrent program logics

Recent developments in concurrent program logics Recent developments in concurrent program logics Viktor Vafeiadis University of Cambridge PSPL 2010 Why program logic? Reasoning framework Capture common reasoning principles Reduce accidental proof complexity

More information

Solution suggestions for examination of Logic, Algorithms and Data Structures,

Solution suggestions for examination of Logic, Algorithms and Data Structures, Department of VT12 Software Engineering and Managment DIT725 (TIG023) Göteborg University, Chalmers 24/5-12 Solution suggestions for examination of Logic, Algorithms and Data Structures, Date : April 26,

More information

Sequential Logic. Road Traveled So Far

Sequential Logic. Road Traveled So Far Comp 2 Spring 25 2/ Lecture page Sequential Logic These must be the slings and arrows of outrageous fortune ) Synchronous as an implementation of Sequential 2) Synchronous Timing Analysis 3) Single synchronous

More information

Program Analysis Part I : Sequential Programs

Program Analysis Part I : Sequential Programs Program Analysis Part I : Sequential Programs IN5170/IN9170 Models of concurrency Program Analysis, lecture 5 Fall 2018 26. 9. 2018 2 / 44 Program correctness Is my program correct? Central question for

More information

HW8. Due: November 1, 2018

HW8. Due: November 1, 2018 CSCI 1010 Theory of Computation HW8 Due: November 1, 2018 Attach a fully filled-in cover sheet to the front of your printed homework Your name should not appear anywhere; the cover sheet and each individual

More information

Verifying Concurrent Programs

Verifying Concurrent Programs Lesson 4 Verifying Concurrent Programs Advanced Critical Section Solutions Ch 4.1-3, App B [BenA 06] Ch 5 (no proofs) [BenA 06] Propositional Calculus Invariants Temporal Logic Automatic Verification Bakery

More information

Solutions. Prelim 2[Solutions]

Solutions. Prelim 2[Solutions] Prelim [Solutions]. Short Answer [ pts] (a) [ pts] A traversal of an expression tree produces the string + + 3. i. What kind of traversal is it? Preorder; the operator is printed before the operands. ii.

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Reminder: Homework 1 due tonight at 11:59PM! Recap: Greedy Algorithms Interval Scheduling Goal: Maximize number of meeting

More information

CSE370: Introduction to Digital Design

CSE370: Introduction to Digital Design CSE370: Introduction to Digital Design Course staff Gaetano Borriello, Brian DeRenzi, Firat Kiyak Course web www.cs.washington.edu/370/ Make sure to subscribe to class mailing list (cse370@cs) Course text

More information

Mathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018

Mathematical Foundations of Programming. Nicolai Kraus. Draft of February 15, 2018 Very short lecture notes: Mathematical Foundations of Programming University of Nottingham, Computer Science, module code G54FOP, Spring 2018 Nicolai Kraus Draft of February 15, 2018 What is this? This

More information

Quiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts)

Quiz 1 Solutions. Problem 2. Asymptotics & Recurrences [20 points] (3 parts) Introduction to Algorithms October 13, 2010 Massachusetts Institute of Technology 6.006 Fall 2010 Professors Konstantinos Daskalakis and Patrick Jaillet Quiz 1 Solutions Quiz 1 Solutions Problem 1. We

More information

Counting Networks 1. August 4, Abstract. Many fundamental multi-processor coordination problems can be expressed as

Counting Networks 1. August 4, Abstract. Many fundamental multi-processor coordination problems can be expressed as Counting Networks 1 James Aspnes y Maurice Herlihy z Nir Shavit x August 4, 1993 Abstract Many fundamental multi-processor coordination problems can be expressed as counting problems: processes must cooperate

More information

Multicore Semantics and Programming

Multicore Semantics and Programming Multicore Semantics and Programming Peter Sewell Tim Harris University of Cambridge Oracle October November, 2015 p. 1 These Lectures Part 1: Multicore Semantics: the concurrency of multiprocessors and

More information

process arrival time CPU burst time priority p1 0ms 25ms 3 p2 1ms 9ms 1 p3 20ms 14ms 4 p4 32ms 4ms 2

process arrival time CPU burst time priority p1 0ms 25ms 3 p2 1ms 9ms 1 p3 20ms 14ms 4 p4 32ms 4ms 2 Homework #2 Solutions 1. Suppose that the following processes arrive for execution at the times indicated. Each process will run with a single burst of CPU activity (i.e., no I/O) which lasts for the listed

More information

CS 700: Quantitative Methods & Experimental Design in Computer Science

CS 700: Quantitative Methods & Experimental Design in Computer Science CS 700: Quantitative Methods & Experimental Design in Computer Science Sanjeev Setia Dept of Computer Science George Mason University Logistics Grade: 35% project, 25% Homework assignments 20% midterm,

More information

1. When applied to an affected person, the test comes up positive in 90% of cases, and negative in 10% (these are called false negatives ).

1. When applied to an affected person, the test comes up positive in 90% of cases, and negative in 10% (these are called false negatives ). CS 70 Discrete Mathematics for CS Spring 2006 Vazirani Lecture 8 Conditional Probability A pharmaceutical company is marketing a new test for a certain medical condition. According to clinical trials,

More information

Reading and Writing. Mathematical Proofs. Slides by Arthur van Goetham

Reading and Writing. Mathematical Proofs. Slides by Arthur van Goetham Reading and Writing Mathematical Proofs Slides by Arthur van Goetham What is a proof? Why explanations are not proofs What is a proof? A method for establishing truth What establishes truth depends on

More information

Deadlock. CSE 2431: Introduction to Operating Systems Reading: Chap. 7, [OSC]

Deadlock. CSE 2431: Introduction to Operating Systems Reading: Chap. 7, [OSC] Deadlock CSE 2431: Introduction to Operating Systems Reading: Chap. 7, [OSC] 1 Outline Resources Deadlock Deadlock Prevention Deadlock Avoidance Deadlock Detection Deadlock Recovery 2 Review: Synchronization

More information

Deterministic planning

Deterministic planning Chapter 3 Deterministic planning The simplest planning problems involves finding a sequence of actions that lead from a given initial state to a goal state. Only deterministic actions are considered. Determinism

More information

Introduction to Parallel Programming in OpenMP Dr. Yogish Sabharwal Department of Computer Science & Engineering Indian Institute of Technology, Delhi

Introduction to Parallel Programming in OpenMP Dr. Yogish Sabharwal Department of Computer Science & Engineering Indian Institute of Technology, Delhi Introduction to Parallel Programming in OpenMP Dr. Yogish Sabharwal Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 33 Parallel LU Factorization So, now, how

More information

Dictionary: an abstract data type

Dictionary: an abstract data type 2-3 Trees 1 Dictionary: an abstract data type A container that maps keys to values Dictionary operations Insert Search Delete Several possible implementations Balanced search trees Hash tables 2 2-3 trees

More information

Turing Machines Part Three

Turing Machines Part Three Turing Machines Part Three What problems can we solve with a computer? What kind of computer? Very Important Terminology Let M be a Turing machine. M accepts a string w if it enters an accept state when

More information

Maps performance tips On server: Maintain DB connections, prepared statements (per thread/request!)

Maps performance tips On server: Maintain DB connections, prepared statements (per thread/request!) Announcements Maps performance tips On server: Maintain DB connections, prepared statements (per thread/request!) Use Spark.before, Spark.after to open and close. Use ThreadLocal, or pass the connection

More information

CSE 502 Class 11 Part 2

CSE 502 Class 11 Part 2 CSE 502 Class 11 Part 2 Jeremy Buhler Steve Cole February 17 2015 Today: analysis of hashing 1 Constraints of Double Hashing How does using OA w/double hashing constrain our hash function design? Need

More information

VLSI Physical Design Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

VLSI Physical Design Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur VLSI Physical Design Prof. Indranil Sengupta Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 54 Design for Testability So, in the last lecture we talked

More information

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis Lecture 14 Class URL: http://vlsicad.ucsd.edu/courses/cse21-s14/ Lecture 14 Notes Goals for this week Big-O complexity

More information

Lecture Notes on Programs with Arrays

Lecture Notes on Programs with Arrays 15-414: Bug Catching: Automated Program Verification Lecture Notes on Programs with Arrays Matt Fredrikson Ruben Martins Carnegie Mellon University Lecture 6 1 Introduction The previous lecture focused

More information

arxiv: v1 [cs.dc] 9 Feb 2015

arxiv: v1 [cs.dc] 9 Feb 2015 Why Transactional Memory Should Not Be Obstruction-Free Petr Kuznetsov 1 Srivatsan Ravi 2 1 Télécom ParisTech 2 TU Berlin arxiv:1502.02725v1 [cs.dc] 9 Feb 2015 Abstract Transactional memory (TM) is an

More information

Automata-Theoretic Model Checking of Reactive Systems

Automata-Theoretic Model Checking of Reactive Systems Automata-Theoretic Model Checking of Reactive Systems Radu Iosif Verimag/CNRS (Grenoble, France) Thanks to Tom Henzinger (IST, Austria), Barbara Jobstmann (CNRS, Grenoble) and Doron Peled (Bar-Ilan University,

More information