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 CoarseGrainedBankTest
on Linux or MacOSgradlew test --tests CoarseGrainedBankTest
on 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 FineGrainedBankTest
on Linux or MacOSgradlew test --tests FineGrainedBankTest
on Windows
In src/day1/TreiberStack.kt
,
implement the classic Treiber stack algorithm.
To test your solution, please run:
./gradlew test --tests TreiberStackTest
on Linux or MacOSgradlew test --tests TreiberStackTest
on 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 TreiberStackWithEliminationTest
on Linux or MacOSgradlew test --tests TreiberStackWithEliminationTest
on 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 MSQueueTest
on Linux or MacOSgradlew test --tests MSQueueTest
on Windows