#
aee00751 |
|
17-Dec-2014 |
Zaheer Chothia <zchothia@inf.ethz.ch> |
posixcompat: make pthread_once a wrapper over the version in libbarrelfish Summary: Both the pthread and native versions now share a single common implementation (added in D9). The new approach should also be faster since it avoids a full mutex and instead only has to consult the per-thread epoch on the common path. I should note, I have not run any benchmarks to confirm this and may be wrong. Test Plan: Compiles but have not validated more thoroughly. Differential Revision: https://code.systems.ethz.ch/D12 Signed-off-by: Zaheer Chothia <zchothia@inf.ethz.ch>
|
#
f8cc9635 |
|
14-Dec-2014 |
Zaheer Chothia <zchothia@inf.ethz.ch> |
thread: add support for one-time global initialization Summary: This is an action that needs to be coordinated globally but the implementation doesn't have to be as pessimistic. The initialization function is only run once and the common case is checking whether it has already been run. The idea here is to have a fast and slow path and let each thread use a locally cached value. Test Plan: Tested with the small code snippet below. Initialization function ran correctly (and only once). For correctness of the locking scheme I defer to the proposal document referred to in the header comment of `lib/barrelfish/thread_once.c`. lang=c #include <barrelfish/threads.h> static thread_once_t init = THREAD_ONCE_INIT; static void init_func(void) { printf("init\n"); } int main() { thread_once(&init, init_func); printf("Hello World\n"); thread_once(&init, init_func); return 0; } Differential Revision: https://code.systems.ethz.ch/D9 Signed-off-by: Zaheer Chothia <zchothia@inf.ethz.ch>
|