diff options
Diffstat (limited to 'src/backend/storage/buffer/s_lock.c')
-rw-r--r-- | src/backend/storage/buffer/s_lock.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/backend/storage/buffer/s_lock.c b/src/backend/storage/buffer/s_lock.c index a7b42bc4793..439240a386f 100644 --- a/src/backend/storage/buffer/s_lock.c +++ b/src/backend/storage/buffer/s_lock.c @@ -7,13 +7,14 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/s_lock.c,v 1.12 1998/09/18 17:18:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/Attic/s_lock.c,v 1.13 1998/12/15 12:46:21 vadim Exp $ * *------------------------------------------------------------------------- */ #include <stdio.h> #include <sys/time.h> +#include <unistd.h> #include "config.h" #include "c.h" @@ -52,6 +53,16 @@ s_lock_stuck(volatile slock_t *lock, const char *file, const int line) } +void +s_lock_sleep(unsigned spin) +{ + struct timeval delay; + + delay.tv_sec = 0; + delay.tv_usec = s_spincycle[spin % S_NSPINCYCLE]; + (void) select(0, NULL, NULL, NULL, &delay); +} + /* * s_lock(lock) - take a spinlock with backoff @@ -59,15 +70,11 @@ s_lock_stuck(volatile slock_t *lock, const char *file, const int line) void s_lock(volatile slock_t *lock, const char *file, const int line) { - int spins = 0; + unsigned spins = 0; while (TAS(lock)) { - struct timeval delay; - - delay.tv_sec = 0; - delay.tv_usec = s_spincycle[spins % S_NSPINCYCLE]; - (void) select(0, NULL, NULL, NULL, &delay); + s_lock_sleep(spins); if (++spins > S_MAX_BUSY) { /* It's been over a minute... */ |