Warning
This page is located in archive. Go to the latest version of this course pages.

Non-blocking Algorithms

Your task is to implement a concurrent set of integers implemented as a skip list without using locks.

Presentation in PDF

  1. Start with the implementation of the set using simple linked list.
  2. Implement the set with AtomicMarkableReference<Type> holding reference to the next node and the mark if this node holding the reference is logically deleted
    1. 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.
    2. 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.
    3. Implement add(int value) method.
  3. Implement wait-free contains(int value) method. The method is read-only.

Homework Assignment

  1. Generalize the previous algorithm to a skip list. Use the template from https://gitlab.fel.cvut.cz/cuchymar/nonblock-skiplist-template.git
    1. 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.
    2. 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.
    3. Implement add and delete methods
    4. 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.
  2. Upload the source code of NonblockSkipListSet together with the test classes you implemented to 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:

  • vmlens - examples provided in the template of the assignment and also on the website of the tool
  • jcstress - OpenJDK tool with code samples provided
  • Java Pathfinder - Tool developed by NASA for model checking of java bytecode programs.
courses/b4m36esw/labs/lab05.txt · Last modified: 2020/03/23 13:53 by cuchymar