diff options
author | Keith Bostic <keith.bostic@mongodb.com> | 2017-01-16 20:27:05 -0500 |
---|---|---|
committer | Alex Gorrod <alexander.gorrod@mongodb.com> | 2017-01-17 12:27:05 +1100 |
commit | 04923774e5ede7a16c45ea31bd020e153a2a7666 (patch) | |
tree | 465c0f8ec7c8de28042998dedbe83d136d301c34 | |
parent | 4da006a05bf3e01ebbfcfd7d55ee67e84413f44a (diff) | |
download | mongo-04923774e5ede7a16c45ea31bd020e153a2a7666.tar.gz |
WT-3127 Fix a bug: CPU yield calls don't necessarily imply memory barriers (#3244)
Add a full-barrier as part of the yield call.
-rw-r--r-- | src/os_posix/os_yield.c | 8 | ||||
-rw-r--r-- | src/os_win/os_yield.c | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/os_posix/os_yield.c b/src/os_posix/os_yield.c index 37d05bc1854..f7c43aae746 100644 --- a/src/os_posix/os_yield.c +++ b/src/os_posix/os_yield.c @@ -16,5 +16,13 @@ void __wt_yield(void) WT_GCC_FUNC_ATTRIBUTE((visibility("default"))) { + /* + * Yielding the processor isn't documented as a memory barrier, and it's + * a reasonable expectation to have. There's no reason not to explicitly + * include a barrier since we're giving up the CPU, and ensures callers + * aren't ever surprised. + */ + WT_FULL_BARRIER(); + sched_yield(); } diff --git a/src/os_win/os_yield.c b/src/os_win/os_yield.c index aab1559e072..038f2efe162 100644 --- a/src/os_win/os_yield.c +++ b/src/os_win/os_yield.c @@ -15,5 +15,13 @@ void __wt_yield(void) { + /* + * Yielding the processor isn't documented as a memory barrier, and it's + * a reasonable expectation to have. There's no reason not to explicitly + * include a barrier since we're giving up the CPU, and ensures callers + * aren't ever surprised. + */ + WT_FULL_BARRIER(); + SwitchToThread(); } |