HomePhabricator

Implement RCU synchronization mechanism

Description

Implement RCU synchronization mechanism

Summary:
This is a userspace implementation of the RCU synchronization primitives.

It is achieved by using a structure per thread in thread local storage. The structures are put together in a linked list that can be traversed lock free by the synchronize operation. The structures are removed from the linkedlist when a thread is shut down.

The synchronization is based on a global revision variable which works in a way similar to source control. The synchronize operation increment the revision and wait for each thread is eithernotholding the lock or have advanced past the revision numer to consider a given state synchronized.

Each thread keep track of the revision it has reached when acquiring the RCULock in its threadlocal datastructure. When the lock is released, a special value is put in the local state indicating that the thread is not currently holding the lock.

Test Plan: Added unit test to cover the whole mechanism and check each intermediate step. Ran the test with COUNT = 4000000 .

Reviewers: #bitcoin_abc, Fabien, jasonbcox

Reviewed By: #bitcoin_abc, Fabien, jasonbcox

Subscribers: jasonbcox, Fabien, teamcity, schancel

Differential Revision: https://reviews.bitcoinabc.org/D2245

Details

Provenance
deadalnixAuthored on Dec 22 2018, 18:33
FabienPushed on Jan 11 2019, 15:21
Reviewer
Restricted Project
Differential Revision
D2245: Implement RCU synchronization mechanism
Parents
rSTAGING6075a015b0f1: Update gen-manpages instructions in release-process.md
Branches
Unknown
Tags
Unknown