In src/day1/CoarseGrainedBank.kt,
make the sequential bank implementation thread-safe.
Please follow the coarse-grained locking scheme to make synchronization efficient.
For that, you need to use a single lock to protect all bank operations.
To test your solution, please run:
./gradlew test --tests CoarseGrainedBankTeston Linux or MacOSgradlew test --tests CoarseGrainedBankTeston Windows
In src/day1/FineGrainedBank.kt,
make the sequential bank implementation thread-safe.
Please follow the fine-grained locking scheme to make synchronization efficient.
For that, you need to use per-account locks, thus, ensuring natural parallelism
when accessing different accounts. The totalAmount() function should acquire
all the locks to get a consistent snapshot, while transfer(..) should acquire
the corresponding account locks.
To test your solution, please run:
./gradlew test --tests FineGrainedBankTeston Linux or MacOSgradlew test --tests FineGrainedBankTeston Windows
In src/day1/TreiberStack.kt,
implement the classic Treiber stack algorithm.
To test your solution, please run:
./gradlew test --tests TreiberStackTeston Linux or MacOSgradlew test --tests TreiberStackTeston Windows
In src/day1/TreiberStackWithElimination.kt,
implement the classic Treiber stack algorithm with the elimination technique.
To test your solution, please run:
./gradlew test --tests TreiberStackWithEliminationTeston Linux or MacOSgradlew test --tests TreiberStackWithEliminationTeston Windows
In src/day1/MSQueue.kt,
implement the Michael-Scott queue algorithm.
You might also be interested in the original paper.
To test your solution, please run:
./gradlew test --tests MSQueueTeston Linux or MacOSgradlew test --tests MSQueueTeston Windows
In src/day2/FAABasedQueueSimplified.kt,
implement a concurrent queue that leverages the Fetch-and-Add synchronization primitive.
The high-level design of this queue bases on a conceptually infinite array for storing elements and manipulates
enqIdx and deqIdx counters, which reference the next working cells in the infinite array for enqueue(..)
and dequeue() operations.
In this task, use a big plain array as the infinite array implementation.
To test your solution, please run:
./gradlew test --tests FAABasedQueueSimplifiedTeston Linux or MacOSgradlew test --tests FAABasedQueueSimplifiedTeston Windows
In src/day2/FAABasedQueue.kt,
implement a concurrent queue that leverages the Fetch-and-Add synchronization primitive.
The high-level design of this queue bases on a conceptually infinite array for storing elements and manipulates
enqIdx and deqIdx counters, which reference the next working cells in the infinite array for enqueue(..)
and dequeue() operations.
The infinite array implementation should be simulated via a linked list of fixed-size segments. The overall algorithm should be obstruction-free or lock-free.
To test your solution, please run:
./gradlew test --tests FAABasedQueueTeston Linux or MacOSgradlew test --tests FAABasedQueueTeston Windows
In src/day2/MSQueueWithOnlyLogicalRemove.kt,
implement a Michael-Scott queue with an additional remove(element) operation.
The implementation should remove elements only logically, keeping the corresponding nodes
in the linked list physically, but marking them as removed.
To test your solution, please run:
./gradlew test --tests MSQueueWithOnlyLogicalRemoveTeston Linux or MacOSgradlew test --tests MSQueueWithOnlyLogicalRemoveTeston Windows
In src/day2/MSQueueWithLinearTimeNonParallelRemove.kt,
implement a Michael-Scott queue with an additional remove(element) operation.
The implementation should find the first node that contains the specified element
in linear time and then remove this node also in linear time.
Note that in this task remove(..) operations are never called in parallel, which simplifies the implementation.
To test your solution, please run:
./gradlew test --tests MSQueueWithLinearTimeNonParallelRemoveTeston Linux or MacOSgradlew test --tests MSQueueWithLinearTimeNonParallelRemoveTeston Windows
In src/day2/MSQueueWithLinearTimeRemove.kt,
implement a Michael-Scott queue with an additional remove(element) operation.
The implementation should find the first node that contains the specified element
in linear time and then remove this node also in linear time.
To test your solution, please run:
./gradlew test --tests MSQueueWithLinearTimeRemoveTeston Linux or MacOSgradlew test --tests MSQueueWithLinearTimeRemoveTeston Windows
In src/day2/MSQueueWithLinearTimeRemove.kt,
implement a Michael-Scott queue with an additional remove(element) operation.
The implementation should find the first node that contains the specified element
in linear time, but remove this node in constant time.
./gradlew test --tests MSQueueWithConstantTimeRemoveTeston Linux or MacOSgradlew test --tests MSQueueWithConstantTimeRemoveTeston Windows
In src/day3/AtomicArrayWithCAS2SingleWriter.kt,
implement the cas2(..) and get(..) operations.
In this data task, CAS2(..) can be called only in one thread,
so concurrent CAS2(..) invocations are forbidden.
To test your solution, please run:
./gradlew test --tests AtomicArrayWithCAS2SingleWriterTeston Linux or MacOSgradlew test --tests AtomicArrayWithCAS2SingleWriterTeston Windows
In src/day3/AtomicArrayWithCAS2Simplified.kt,
implement the cas2(..) operation. In this data task, all successful updates
install unique values in the array cells.
To test your solution, please run:
./gradlew test --tests AtomicArrayWithCAS2SimplifiedTeston Linux or MacOSgradlew test --tests AtomicArrayWithCAS2SimplifiedTeston Windows
In src/day3/AtomicArrayWithDCSS.kt,
implement the dcss(..) operation. Similarly to CAS2, it requires
allocating a descriptor and installing it in the updating memory location.
We need the dcss(..) operation for the next task, to resolve the ABA-problem
in the CAS2 algorithm.
To test your solution, please run:
./gradlew test --tests AtomicArrayWithDCSSTeston Linux or MacOSgradlew test --tests AtomicArrayWithDCSSTeston Windows
In src/day3/AtomicArrayWithCAS2.kt,
implement the cas2(..) operation.
Unlike in the "CAS2: Simplified" task, updates are no longer unique.
This can lead to the ABA problem. To solve it, please use
the Double-Compare-Single-Set operation when installing CAS2 descriptors.
To test your solution, please run:
./gradlew test --tests AtomicArrayWithCAS2Teston Linux or MacOSgradlew test --tests AtomicArrayWithCAS2Teston Windows