mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Initial MVCC code.
New code for locking buffer' context.
This commit is contained in:
@@ -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... */
|
||||
|
||||
Reference in New Issue
Block a user