Liorlinked list presentation.ppt - Ordered linked list implementation of a set-∞ a b By Lior Zibi c ∞ Discussion Topics • Defining the set and the

Liorlinked list presentation.ppt - Ordered linked list...

This preview shows page 1 - 18 out of 140 pages.

Ordered linked list implementation of a set By Lior Zibi a b c -∞ +∞
Image of page 1

Subscribe to view the full document.

Discussion Topics Defining the set and the linked list implementation. Some definitions. Algorithms: 1. Coarse grained synchronization. 2. Fine grained synchronization. 3. Optimistic synchronization. 4. Lazy synchronization.
Image of page 2
Defining the linked list First, Set : Unordered collection of items No duplicates
Image of page 3

Subscribe to view the full document.

Defining the linked list public interface Set<T> { public boolean add(T x); public boolean remove(T x); public boolean contains(T x); } public class Node { public T item; public int key; public Node next; } Now the linked implements:
Image of page 4
5 a b c Sorted with Sentinel nodes (min & max possible keys) -∞ +∞ Defining the linked list
Image of page 5

Subscribe to view the full document.

Defining concurrent methods properties Invariant: Property that always holds. Established because True when object is created. Truth preserved by each method Each step of each method.
Image of page 6
Defining concurrent methods properties Rep-Invariant: The invariant on our concrete Representation = on the list. Preserved by methods. Relied on by methods. Allows us to reason about each method in isolation without considering how they interact.
Image of page 7

Subscribe to view the full document.

Defining concurrent methods properties Our Rep-invariant : Sentinel nodes tail reachable from head. Sorted No duplicates Depends on the implementation.
Image of page 8
Defining concurrent methods properties Abstraction Map : S(List) = { x | there exists a such that a reachable from head and a.item = x } Depends on the implementation.
Image of page 9

Subscribe to view the full document.

10 Abstract Data Types Example: S( ) = { a , b } a b a b Concrete representation: Abstract Type: { a , b }
Image of page 10
Defining concurrent methods properties Wait-free: Every call to the function finishes in a finite number of steps. Supposing the Scheduler is fair: Starvation-free : every thread calling the method eventually returns.
Image of page 11

Subscribe to view the full document.

Algorithms Next: going throw each algorithm. 1. Describing the algorithm. 2. Explaining why every step of the algorithm is needed. 3. Code review. 4. Analyzing each method properties. 5. Advantages / Disadvantages. 6. Presenting running times for my implementation of the algorithm. + Example of proving correctness for Remove(x) in FineGrained. Hopefully… “Formal proofs of correctness lie beyond the scope of this book”
Image of page 12
13 0.Sequential List Based Set a c d a b c Add() Remove()
Image of page 13

Subscribe to view the full document.

14 a c d b a b c Add() Remove() 0.Sequential List Based Set
Image of page 14
15 1 . Course Grained a b d 1. Describing the algorithm: Most common implementation today. Add(x) / Remove(x) / Contains(x): - Lock the entire list then perform the operation.
Image of page 15

Subscribe to view the full document.

16 1 . Course Grained a b d c Most common implementation today 1. Describing the algorithm: All methods perform operations on the list while holding the lock, so the execution is essentially sequential.
Image of page 16
17 3. Code review: Add : public boolean add(T item) { Node pred, curr; int key = item.hashCode(); lock.lock(); try { pred = head; curr = pred.next; while (curr.key < key) { pred = curr; curr = curr.next; } if (key == curr.key) { return false; } else { Node node = new Node(item); node.next = curr;
Image of page 17

Subscribe to view the full document.

Image of page 18
  • Spring '19

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes