diff options
author | Marat Dukhan <maratek@google.com> | 2020-05-08 20:45:20 -0700 |
---|---|---|
committer | Marat Dukhan <maratek@google.com> | 2020-05-08 20:45:20 -0700 |
commit | 6ae95d3d7b407ac310e59958a92bc8be4583340e (patch) | |
tree | fb60f8d8c67d7c3290158d9926d4b4944d1758f0 /src/pthreads.c | |
parent | 5690b5ceada160444a916d31ef72e381f5e52d67 (diff) | |
download | pthreadpool-6ae95d3d7b407ac310e59958a92bc8be4583340e.tar.gz |
Use platform-specific yield/pause instructions
Diffstat (limited to 'src/pthreads.c')
-rw-r--r-- | src/pthreads.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/pthreads.c b/src/pthreads.c index 2d945a0..430ca79 100644 --- a/src/pthreads.c +++ b/src/pthreads.c @@ -108,8 +108,7 @@ static void wait_worker_threads(struct pthreadpool* threadpool) { /* Spin-wait */ for (uint32_t i = PTHREADPOOL_SPIN_WAIT_ITERATIONS; i != 0; i--) { - /* This fence serves as a sleep instruction */ - pthreadpool_fence_acquire(); + pthreadpool_yield(); #if PTHREADPOOL_USE_FUTEX has_active_threads = pthreadpool_load_acquire_uint32_t(&threadpool->has_active_threads); @@ -151,8 +150,7 @@ static uint32_t wait_for_new_command( if ((last_flags & PTHREADPOOL_FLAG_YIELD_WORKERS) == 0) { /* Spin-wait loop */ for (uint32_t i = PTHREADPOOL_SPIN_WAIT_ITERATIONS; i != 0; i--) { - /* This fence serves as a sleep instruction */ - pthreadpool_fence_acquire(); + pthreadpool_yield(); command = pthreadpool_load_acquire_uint32_t(&threadpool->command); if (command != last_command) { |