11~Chapter_13 - Hashing and Natural Parallism Companion...

Info iconThis preview shows pages 1–19. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Hashing and Natural Parallism Companion slides for The Art of Multiprocessor Programming by Maurice Herlihy & Nir Shavit Code Please review the code for the presented data structures from Chapter 13 of the textbook Art of Multiprocessor Programming Herlihy-Shavit 2007 2 Art of Multiprocessor Programming Herlihy-Shavit 2007 3 Linked Lists We looked at a number of ways to make highly- concurrent list-based Sets: Fine-grained locks Optimistic synchronization Lazy synchronization Lock-free synchronization Whats missing? Art of Multiprocessor Programming Herlihy-Shavit 2007 4 Linear-Time Set Methods Problem is add() , remove() , contains() Take time linear in set size We want Constant-time methods (at least, on average) Art of Multiprocessor Programming Herlihy-Shavit 2007 5 Hashing Hash function h : items integers Uniformly distributed Different item most likely have different hash values Java hashCode() method Art of Multiprocessor Programming Herlihy-Shavit 2007 6 Sequential Hash Map 1 2 3 16 9 h(k) = k mod 4 2 Items buckets Art of Multiprocessor Programming Herlihy-Shavit 2007 7 Add an Item 1 2 3 16 9 7 h(k) = k mod 4 3 Items Art of Multiprocessor Programming Herlihy-Shavit 2007 8 Add Another: Collision 1 2 3 16 4 9 7 h(k) = k mod 4 4 Items Art of Multiprocessor Programming Herlihy-Shavit 2007 9 More Collisions 1 2 3 16 4 9 7 15 h(k) = k mod 4 5 Items Art of Multiprocessor Programming Herlihy-Shavit 2007 10 More Collisions 1 2 3 16 4 9 7 15 h(k) = k mod 4 5 Items Problem: buckets getting too long Art of Multiprocessor Programming Herlihy-Shavit 2007 11 Resizing 1 2 3 16 4 9 7 15 4 5 6 7 Grow the array 5 Items h(k) = k mod 8 Art of Multiprocessor Programming Herlihy-Shavit 2007 12 5 Items Resizing 1 2 3 16 4 9 7 15 4 5 6 7 h(k) = k mod 8 Adjust hash function Art of Multiprocessor Programming Herlihy-Shavit 2007 13 Resizing 1 2 3 16 9 7 15 h(4) = 0 mod 8 4 5 6 7 4 h(k) = k mod 8 Art of Multiprocessor Programming Herlihy-Shavit 2007 14 Resizing 1 2 3 16 4 9 7 15 4 5 6 7 h(k) = k mod 8 h(4) = 4 mod 8 Art of Multiprocessor Programming Herlihy-Shavit 2007 15 Resizing 1 2 3 16 4 9 7 15 4 5 6 7 h(k) = k mod 8 h(15) = 7 mod 8 Art of Multiprocessor Programming Herlihy-Shavit 2007 16 Resizing 1 2 3 16 4 9 4 5 6 7 h(k) = k mod 8 h(15) = 7 mod 8 15 7 Art of Multiprocessor Programming Herlihy-Shavit 2007 17 Hash Sets Implement a Set object Collection of items, no duplicates add() , remove() , contains() methods You know the drill Art of Multiprocessor Programming Herlihy-Shavit 2007 18 Simple Hash Set public class SimpleHashSet {...
View Full Document

This note was uploaded on 11/09/2011 for the course ENGINEERIN 247 taught by Professor Staff during the Fall '09 term at Rutgers.

Page1 / 135

11~Chapter_13 - Hashing and Natural Parallism Companion...

This preview shows document pages 1 - 19. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online