#include <unistd.h>
#include "compiler.h"
#include "hash.h"
+#include "ovs-rcu.h"
#include "poll-loop.h"
#include "socket-util.h"
#include "util.h"
ovs_mutex_cond_wait(pthread_cond_t *cond, const struct ovs_mutex *mutex_)
{
struct ovs_mutex *mutex = CONST_CAST(struct ovs_mutex *, mutex_);
- int error = pthread_cond_wait(cond, &mutex->lock);
+ int error;
+
+ ovsrcu_quiesce_start();
+ error = pthread_cond_wait(cond, &mutex->lock);
+ ovsrcu_quiesce_end();
+
if (OVS_UNLIKELY(error)) {
ovs_abort(error, "pthread_cond_wait failed");
}
aux = *auxp;
free(auxp);
+ ovsrcu_quiesce_end();
return aux.start(aux.arg);
}
forbid_forking("multiple threads exist");
multithreaded = true;
+ ovsrcu_quiesce_end();
aux = xmalloc(sizeof *aux);
aux->start = start;
ovs_mutex_unlock(&once->mutex);
}
\f
+bool
+single_threaded(void)
+{
+ return !multithreaded;
+}
+
/* Asserts that the process has not yet created any threads (beyond the initial
* thread).
*