mesos-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joseph Wu" <>
Subject Re: Review Request 39949: Document and simplify libprocess initialization synchronization logic.
Date Fri, 20 Nov 2015 19:16:34 GMT

This is an automatically generated e-mail. To reply, visit:

(Updated Nov. 20, 2015, 11:16 a.m.)

Review request for mesos, Benjamin Hindman, Joris Van Remoortere, and Neil Conway.



Bugs: MESOS-3864

Repository: mesos


* Renamed `initialized` to `initialize_started`.
* Renamed `initializing` to `initialize_complete`.
* Removed the (2) condition, described below: 

The initialization synchronization logic contains three conditions, which check:
1) Was `initialize` called and is it done?
2) Was `initialize` called and is it not done?
3) Are you the first to call `initialize`?

Condition (3) uses `compare_exchange_strong` between `initialized` and `false`.  This returns
`true` (and sets `initialized` to true) iff the caller is the first to reach that expression.

The second simultaneous caller of `initialize` will either satisify condition (2) or (3) and
then wait on `initializing`.  For the second caller, (2) and (3) are identical because `compare_exchange_strong`
between `true` and `false` will always return false, thereby putting the second caller into
the waiting loop.

Diffs (updated)

  3rdparty/libprocess/src/process.cpp 8fa0594b671969c2713d1b361f2dbbb07d25b3a8 



`make check`

Replaced `process::initialize();` in `3rdparty/libprocess/src/tests/main.cpp` with:

  const size_t numThreads = 50;

  std::thread* runningThreads[numThreads];

  // Create additional threads.
  for (size_t i = 0; i < numThreads; i++) {
    runningThreads[i] = new std::thread([]() {

  for (size_t i = 0; i < numThreads; i++) {
    delete runningThreads[i];
(Also added `#include <thread>` to the header).

Rebuilt `libprocess-tests` with the modification and ran it a few times.


Joseph Wu

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message