Deleted
Added
1 2/* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_main.h> 8 9 10/* 11 * Linux supports pthread spinlocks since glibc 2.3. Spinlock is an 12 * atomic integer with zero initial value. On i386/amd64 however the 13 * initial value is one. Spinlock never yields control. 14 * 15 * FreeBSD 5.2 and Solaris 10 support pthread spinlocks. Spinlock is a 16 * structure and uses mutex implementation so it must be initialized by 17 * by pthread_spin_init() and destroyed by pthread_spin_destroy(). |
18 * 19 * MacOSX supported OSSpinLockLock(), it was deprecated in 10.12 (Sierra). |
20 * OSSpinLockLock() tries to acquire a lock atomically. If the lock is 21 * busy, on SMP system it tests the lock 1000 times in a tight loop with 22 * "pause" instruction. If the lock has been released, OSSpinLockLock() 23 * tries to acquire it again. On failure it goes again in the tight loop. 24 * If the lock has not been released during spinning in the loop or 25 * on UP system, OSSpinLockLock() calls thread_switch() to run 1ms 26 * with depressed (the lowest) priority. 27 */ 28 |
29 |
30/* It should be adjusted with the "spinlock_count" directive. */ 31static nxt_uint_t nxt_spinlock_count = 1000; 32 33 34void 35nxt_thread_spin_init(nxt_uint_t ncpu, nxt_uint_t count) 36{ 37 switch (ncpu) { --- 67 unchanged lines hidden (view full) --- 105 106void 107nxt_thread_spin_unlock(nxt_thread_spinlock_t *lock) 108{ 109 nxt_atomic_release(lock); 110 111 nxt_thread_log_debug("spin_unlock(%p) exit", lock); 112} |