diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-12-27 20:58:58 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-12-27 20:58:58 +0000 |
commit | f8eed65dfb580f0971e2e6ead83135bfa3ddeb06 (patch) | |
tree | 5fd8b3b152cfa785e14a4489b628081a67dcf2d9 /src/backend | |
parent | 2cdace962b5fd56a4bd2fae1c1ba6e99434f33f3 (diff) | |
download | postgresql-f8eed65dfb580f0971e2e6ead83135bfa3ddeb06.tar.gz postgresql-f8eed65dfb580f0971e2e6ead83135bfa3ddeb06.zip |
Improve spinlock code for recent x86 processors: insert a PAUSE
instruction in the s_lock() wait loop, and use test before test-and-set
in TAS() macro to avoid unnecessary bus traffic. Patch from Manfred
Spraul, reworked a bit by Tom.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/storage/lmgr/s_lock.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c index e5e372bb39d..fac77aef0af 100644 --- a/src/backend/storage/lmgr/s_lock.c +++ b/src/backend/storage/lmgr/s_lock.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.22 2003/12/23 22:15:07 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/s_lock.c,v 1.23 2003/12/27 20:58:58 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -88,6 +88,10 @@ s_lock(volatile slock_t *lock, const char *file, int line) while (TAS(lock)) { + /* CPU-specific delay each time through the loop */ + SPIN_DELAY(); + + /* Block the process every SPINS_PER_DELAY tries */ if (++spins > SPINS_PER_DELAY) { if (++delays > NUM_DELAYS) |