Skip to content

Commit b4c6963

Browse files
committed
avoid race between a scheduler starting up and an enclave trying to acquire.
1 parent 4e75aec commit b4c6963

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

include/reactor-cpp/scheduler.hh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ private:
110110

111111
std::mutex scheduling_mutex_;
112112
std::condition_variable cv_schedule_;
113+
// lock used to protect the scheduler from asynchronous requests (i.e. from
114+
// enclaves pr federates). We hold the mutex from construction and release in
115+
// start().
116+
std::unique_lock<std::mutex> startup_lock_{scheduling_mutex_};
113117

114118
std::shared_mutex mutex_event_queue_;
115119
std::map<Tag, ActionListPtr> event_queue_;

lib/scheduler.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ void Scheduler::start() {
214214
set_ports_.resize(num_workers);
215215
triggered_reactions_.resize(num_workers);
216216

217+
// release the scheduling mutex, allowing other asynchronous processes (i.e.
218+
// enclaves or federates) to access the event queue and the current logical
219+
// time.
220+
startup_lock_.unlock();
221+
217222
// Initialize and start the workers. By resizing the workers vector first,
218223
// we make sure that there is sufficient space for all the workers and non of
219224
// them needs to be moved. This is important because a running worker may not

0 commit comments

Comments
 (0)