Changeset View
Changeset View
Standalone View
Standalone View
src/rcu.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
* scratch. | * scratch. | ||||
* | * | ||||
* /----------------------| | * /----------------------| | ||||
* | V | * | V | ||||
* threadInfos Ndelete -> Nchild | * threadInfos Ndelete -> Nchild | ||||
* ^ | * ^ | ||||
* Nadded -| | * Nadded -| | ||||
* | * | ||||
* After a succesful deletion, threadInfos now points to NChild and the CAS to | * After a successful deletion, threadInfos now points to NChild and the CAS to | ||||
* move it to Nadded will fail, causing the insertion process to fail. | * move it to Nadded will fail, causing the insertion process to fail. | ||||
* | * | ||||
* We also run into problems when several nodes are deleted concurrently. | * We also run into problems when several nodes are deleted concurrently. | ||||
* Because it is not possible to read Ndelete->next and update Nparent->next | * Because it is not possible to read Ndelete->next and update Nparent->next | ||||
* atomically, we may end up setting Nparent->next to a stale value if Nchild is | * atomically, we may end up setting Nparent->next to a stale value if Nchild is | ||||
* deleted. | * deleted. | ||||
* | * | ||||
* /----------------------| | * /----------------------| | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | for (int i = 0; i < RCU_ACTIVE_LOOP_COUNT; i++) { | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
// It seems like we have some contention. Let's try to not starve the | // It seems like we have some contention. Let's try to not starve the | ||||
// system. Let's make sure threads that land here proceed one by one. | // system. Let's make sure threads that land here proceed one by one. | ||||
// XXX: The best option long term is most likely to use a futex on one of | // XXX: The best option long term is most likely to use a futex on one of | ||||
// the thread causing synchronization delay so this thread can be waked up | // the thread causing synchronization delay so this thread can be waked up | ||||
// at an apropriate time. | // at an appropriate time. | ||||
static std::condition_variable cond; | static std::condition_variable cond; | ||||
static Mutex cs; | static Mutex cs; | ||||
WAIT_LOCK(cs, lock); | WAIT_LOCK(cs, lock); | ||||
do { | do { | ||||
runCleanups(); | runCleanups(); | ||||
cond.notify_one(); | cond.notify_one(); | ||||
} while (!cond.wait_for(lock, std::chrono::microseconds(1), [&] { | } while (!cond.wait_for(lock, std::chrono::microseconds(1), [&] { | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |