====== Non-blocking Algorithms ====== Your task is to implement a concurrent set of integers implemented as a skip list without using locks. Presentation in {{ :courses:b4m36esw:labs:nonblock.pdf |PDF}} ===== Lab Assignment (not mandatory, but recommended) ===== - Start with the implementation of the set using simple linked list. - Download a template from[[https://gitlab.fel.cvut.cz/cuchymar/nonblock-basic-template.git]] - Implement the set with ''AtomicMarkableReference'' holding reference to the next node and the mark if ''this'' node holding the reference is logically deleted - Implement a helper method ''find(int value)'', which traverses the list until it finds the correct position of the value and deletes the marked nodes during the traversal. - Implement the ''delete(int value)'' method with marking of the deleted node beforehand (logical deletion) and with other threads helping with the physical deletion if they find any marked node. - Implement ''add(int value)'' method. - Implement wait-free contains(int value) method. The method is read-only. ===== Homework Assignment ===== - Generalize the previous algorithm to a skip list. Use the template from [[https://gitlab.fel.cvut.cz/cuchymar/nonblock-skiplist-template.git]] - To clarify how the skip list works, we recommend to start with the contains method which just goes through the list and tries to find the value (without calling find method). It does not need to change anything in the skip list. This point is not mandatory. - Try to generalize the method find(), to look not only for one predecessor and one successor of the searched value but for the predecessors on all the levels. - Implement add and delete methods - Testing is an important part of implementation of any algorithm therefore your task is also to create tests. Unfortunatelly, testing of concurrent structures is difficult. * Start with testing of only single-thread behaviour (very easy - e.g. classical JUnit). * Try to desing some tests that checks the functionality in a multi-threaded environment. * You have to be able to demonstrate that the algorithm is working correctly. - Upload the source code of ''NonblockSkipListSet'' together with the test classes you implemented to [[https://cw.felk.cvut.cz/brute/teacher/course/1012|BRUTE]]. Please, upload only the mentioned classes - do NOT upload compiled code or libraries). There is no automatic evaluation and the code will be evaluated manually. You will present the code to the tutor and explain what key parts of the code do. ===== Concurrent Testing ===== There is several available tools that can be used: * [[https://vmlens.com/|vmlens]] - examples provided in the template of the assignment and also on the website of the tool * [[https://wiki.openjdk.java.net/display/CodeTools/jcstress|jcstress]] - OpenJDK tool with [[http://hg.openjdk.java.net/code-tools/jcstress/file/tip/jcstress-samples/src/main/java/org/openjdk/jcstress/samples|code samples]] provided * [[https://github.com/javapathfinder/jpf-core/wiki|Java Pathfinder]] - Tool developed by NASA for model checking of java bytecode programs.