aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/include')
-rw-r--r--src/include/storage/buf_internals.h9
-rw-r--r--src/include/storage/bufmgr.h4
-rw-r--r--src/include/storage/ipc.h188
-rw-r--r--src/include/storage/lmgr.h5
-rw-r--r--src/include/storage/proc.h74
-rw-r--r--src/include/storage/s_lock.h50
-rw-r--r--src/include/storage/shmem.h26
-rw-r--r--src/include/storage/sinval.h8
-rw-r--r--src/include/storage/sinvaladt.h8
-rw-r--r--src/include/storage/spin.h15
10 files changed, 158 insertions, 229 deletions
diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h
index fc15e59859b..ae417118878 100644
--- a/src/include/storage/buf_internals.h
+++ b/src/include/storage/buf_internals.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: buf_internals.h,v 1.43 2000/11/08 22:10:02 tgl Exp $
+ * $Id: buf_internals.h,v 1.44 2000/11/28 23:27:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -16,6 +16,7 @@
#include "storage/buf.h"
#include "storage/lmgr.h"
+#include "storage/s_lock.h"
/* Buf Mgr constants */
/* in bufmgr.c */
@@ -100,11 +101,9 @@ typedef struct sbufdesc
BufFlags flags; /* see bit definitions above */
unsigned refcount; /* # of times buffer is pinned */
-#ifdef HAS_TEST_AND_SET
- /* can afford a dedicated lock if test-and-set locks are available */
- slock_t io_in_progress_lock;
+ slock_t io_in_progress_lock; /* to block for I/O to complete */
slock_t cntx_lock; /* to lock access to page context */
-#endif /* HAS_TEST_AND_SET */
+
unsigned r_locks; /* # of shared locks */
bool ri_lock; /* read-intent lock */
bool w_lock; /* context exclusively locked */
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index 22c0ccde7d5..275146eea80 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: bufmgr.h,v 1.43 2000/11/08 22:10:02 tgl Exp $
+ * $Id: bufmgr.h,v 1.44 2000/11/28 23:27:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -154,7 +154,7 @@ extern Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation,
BlockNumber blockNum);
extern int FlushBuffer(Buffer buffer, bool sync, bool release);
-extern void InitBufferPool(IPCKey key);
+extern void InitBufferPool(void);
extern void PrintBufferUsage(FILE *statfp);
extern void ResetBufferUsage(void);
extern void ResetBufferPool(bool isCommit);
diff --git a/src/include/storage/ipc.h b/src/include/storage/ipc.h
index eea082a574e..b633297d5f6 100644
--- a/src/include/storage/ipc.h
+++ b/src/include/storage/ipc.h
@@ -7,14 +7,10 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: ipc.h,v 1.42 2000/10/07 14:39:17 momjian Exp $
- *
- * NOTES
- * This file is very architecture-specific. This stuff should actually
- * be factored into the port/ directories.
+ * $Id: ipc.h,v 1.43 2000/11/28 23:27:57 tgl Exp $
*
* Some files that would normally need to include only sys/ipc.h must
- * instead included this file because on Ultrix, sys/ipc.h is not designed
+ * instead include this file because on Ultrix, sys/ipc.h is not designed
* to be included multiple times. This file (by virtue of the ifndef IPC_H)
* is.
*-------------------------------------------------------------------------
@@ -26,11 +22,9 @@
#include <sys/types.h>
#ifdef HAVE_SYS_IPC_H
-#include <sys/ipc.h> /* For IPC_PRIVATE */
+#include <sys/ipc.h>
#endif /* HAVE_SYS_IPC_H */
-#include "config.h"
-
#ifndef HAVE_UNION_SEMUN
union semun
{
@@ -38,79 +32,41 @@ union semun
struct semid_ds *buf;
unsigned short *array;
};
-
#endif
-typedef uint16 SystemPortAddress;
-
-/* semaphore definitions */
+/* generic IPC definitions */
#define IPCProtection (0600) /* access/modify by user only */
-#define IPC_NMAXSEM 25 /* maximum number of semaphores */
-#define IpcSemaphoreDefaultStartValue 255
-#define IpcSharedLock (-1)
-#define IpcExclusiveLock (-255)
-
-#define IpcUnknownStatus (-1)
-#define IpcInvalidArgument (-2)
-#define IpcSemIdExist (-3)
-#define IpcSemIdNotExist (-4)
-
-typedef uint32 IpcSemaphoreKey; /* semaphore key */
-typedef int IpcSemaphoreId;
-
-/* shared memory definitions */
-
-#define IpcMemCreationFailed (-1)
-#define IpcMemIdGetFailed (-2)
-#define IpcMemAttachFailed 0
-
-typedef uint32 IPCKey;
-
-#define PrivateIPCKey IPC_PRIVATE
-#define DefaultIPCKey 17317
+/* semaphore definitions */
-typedef uint32 IpcMemoryKey; /* shared memory key */
-typedef int IpcMemoryId;
+typedef uint32 IpcSemaphoreKey; /* semaphore key passed to semget(2) */
+typedef int IpcSemaphoreId; /* semaphore ID returned by semget(2) */
+#define IPC_NMAXSEM 32 /* maximum number of semaphores per semID */
-/* ipc.c */
-extern bool proc_exit_inprogress;
+#define PGSemaMagic 537 /* must be less than SEMVMX */
-extern void proc_exit(int code);
-extern void shmem_exit(int code);
-extern int on_shmem_exit(void (*function) (), Datum arg);
-extern int on_proc_exit(void (*function) (), Datum arg);
-extern void on_exit_reset(void);
+/* shared memory definitions */
-extern IpcSemaphoreId IpcSemaphoreCreate(IpcSemaphoreKey semKey,
- int semNum, int permission, int semStartValue,
- int removeOnExit);
-extern void IpcSemaphoreKill(IpcSemaphoreKey key);
-extern void IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock);
-extern void IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock);
-extern int IpcSemaphoreGetCount(IpcSemaphoreId semId, int sem);
-extern int IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem);
-extern IpcMemoryId IpcMemoryCreate(IpcMemoryKey memKey, uint32 size,
- int permission);
-extern IpcMemoryId IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size);
-extern char *IpcMemoryAttach(IpcMemoryId memId);
-extern void IpcMemoryKill(IpcMemoryKey memKey);
-extern void CreateAndInitSLockMemory(IPCKey key);
-extern void AttachSLockMemory(IPCKey key);
+typedef uint32 IpcMemoryKey; /* shared memory key passed to shmget(2) */
+typedef int IpcMemoryId; /* shared memory ID returned by shmget(2) */
+typedef struct /* standard header for all Postgres shmem */
+{
+ int32 magic; /* magic # to identify Postgres segments */
+#define PGShmemMagic 679834892
+ pid_t creatorPID; /* PID of creating process */
+ uint32 totalsize; /* total size of segment */
+ uint32 freeoffset; /* offset to first free space */
+} PGShmemHeader;
-#ifdef HAS_TEST_AND_SET
-#define NOLOCK 0
-#define SHAREDLOCK 1
-#define EXCLUSIVELOCK 2
+/* spinlock definitions */
typedef enum _LockId_
{
BUFMGRLOCKID,
- LOCKLOCKID,
OIDGENLOCKID,
XIDGENLOCKID,
CNTLFILELOCKID,
@@ -118,100 +74,40 @@ typedef enum _LockId_
SHMEMINDEXLOCKID,
LOCKMGRLOCKID,
SINVALLOCKID,
-
-#ifdef STABLE_MEMORY_STORAGE
- MMCACHELOCKID,
-#endif
-
PROCSTRUCTLOCKID,
- FIRSTFREELOCKID
-} _LockId_;
-
-#define MAX_SPINS FIRSTFREELOCKID
-
-typedef struct slock
-{
- slock_t locklock;
- unsigned char flag;
- short nshlocks;
- slock_t shlock;
- slock_t exlock;
- slock_t comlock;
- struct slock *next;
-} SLock;
-
-#else /* HAS_TEST_AND_SET */
-
-typedef enum _LockId_
-{
- SHMEMLOCKID,
- SHMEMINDEXLOCKID,
- BUFMGRLOCKID,
- LOCKMGRLOCKID,
- SINVALLOCKID,
#ifdef STABLE_MEMORY_STORAGE
MMCACHELOCKID,
#endif
- PROCSTRUCTLOCKID,
- OIDGENLOCKID,
- XIDGENLOCKID,
- CNTLFILELOCKID,
- FIRSTFREELOCKID
+ MAX_SPINS /* must be last item! */
} _LockId_;
-#define MAX_SPINS FIRSTFREELOCKID
-#endif /* HAS_TEST_AND_SET */
+/* ipc.c */
+extern bool proc_exit_inprogress;
-/*
- * the following are originally in ipci.h but the prototypes have circular
- * dependencies and most files include both ipci.h and ipc.h anyway, hence
- * combined.
- *
- */
+extern void proc_exit(int code);
+extern void shmem_exit(int code);
+extern void on_proc_exit(void (*function) (), Datum arg);
+extern void on_shmem_exit(void (*function) (), Datum arg);
+extern void on_exit_reset(void);
-/*
- * Note:
- * These must not hash to DefaultIPCKey or PrivateIPCKey.
- */
-#define SystemPortAddressGetIPCKey(address) \
- (28597 * (address) + 17491)
+extern void IpcInitKeyAssignment(int port);
-/*
- * these keys are originally numbered from 1 to 12 consecutively but not
- * all are used. The unused ones are removed. - ay 4/95.
- */
-#define IPCKeyGetBufferMemoryKey(key) \
- ((key == PrivateIPCKey) ? key : 1 + (key))
-
-#define IPCKeyGetSIBufferMemoryBlock(key) \
- ((key == PrivateIPCKey) ? key : 7 + (key))
-
-#define IPCKeyGetSLockSharedMemoryKey(key) \
- ((key == PrivateIPCKey) ? key : 10 + (key))
-
-#define IPCKeyGetSpinLockSemaphoreKey(key) \
- ((key == PrivateIPCKey) ? key : 11 + (key))
-#define IPCKeyGetWaitIOSemaphoreKey(key) \
- ((key == PrivateIPCKey) ? key : 12 + (key))
-#define IPCKeyGetWaitCLSemaphoreKey(key) \
- ((key == PrivateIPCKey) ? key : 13 + (key))
-
-/* --------------------------
- * NOTE: This macro must always give the highest numbered key as every backend
- * process forked off by the postmaster will be trying to acquire a semaphore
- * with a unique key value starting at key+14 and incrementing up. Each
- * backend uses the current key value then increments it by one.
- * --------------------------
- */
-#define IPCGetProcessSemaphoreInitKey(key) \
- ((key == PrivateIPCKey) ? key : 14 + (key))
+extern IpcSemaphoreId IpcSemaphoreCreate(int numSems, int permission,
+ int semStartValue,
+ bool removeOnExit);
+extern void IpcSemaphoreKill(IpcSemaphoreId semId);
+extern void IpcSemaphoreLock(IpcSemaphoreId semId, int sem);
+extern void IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem);
+extern bool IpcSemaphoreTryLock(IpcSemaphoreId semId, int sem);
+extern int IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem);
+
+extern PGShmemHeader *IpcMemoryCreate(uint32 size, bool private,
+ int permission);
/* ipci.c */
-extern IPCKey SystemPortAddressCreateIPCKey(SystemPortAddress address);
-extern void CreateSharedMemoryAndSemaphores(IPCKey key, int maxBackends);
-extern void AttachSharedMemoryAndSemaphores(IPCKey key);
+extern void CreateSharedMemoryAndSemaphores(bool private, int maxBackends);
#endif /* IPC_H */
diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h
index 71a59cb9cc7..f859dc0762f 100644
--- a/src/include/storage/lmgr.h
+++ b/src/include/storage/lmgr.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: lmgr.h,v 1.25 2000/06/08 22:37:54 momjian Exp $
+ * $Id: lmgr.h,v 1.26 2000/11/28 23:27:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,7 +47,4 @@ extern void UnlockPage(Relation relation, BlockNumber blkno, LOCKMODE lockmode);
extern void XactLockTableInsert(TransactionId xid);
extern void XactLockTableWait(TransactionId xid);
-/* proc.c */
-extern void InitProcGlobal(IPCKey key, int maxBackends);
-
#endif /* LMGR_H */
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index edc6359fc43..41305d80831 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -1,13 +1,13 @@
/*-------------------------------------------------------------------------
*
* proc.h
- *
+ * per-process shared memory data structures
*
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: proc.h,v 1.31 2000/05/31 00:28:38 petere Exp $
+ * $Id: proc.h,v 1.32 2000/11/28 23:27:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,9 +23,8 @@ extern int DeadlockTimeout;
typedef struct
{
int sleeplock;
- int semNum;
IpcSemaphoreId semId;
- IpcSemaphoreKey semKey;
+ int semNum;
} SEMA;
/*
@@ -33,7 +32,6 @@ typedef struct
*/
typedef struct proc
{
-
/* proc->links MUST BE THE FIRST ELEMENT OF STRUCT (see ProcWakeup()) */
SHM_QUEUE links; /* proc can be waiting for one event(lock) */
@@ -63,34 +61,6 @@ typedef struct proc
* transaction */
} PROC;
-
-/*
- * PROC_NSEMS_PER_SET is the number of semaphores in each sys-V semaphore set
- * we allocate. It must be *less than* 32 (or however many bits in an int
- * on your machine), or our free-semaphores bitmap won't work. You also must
- * not set it higher than your kernel's SEMMSL (max semaphores per set)
- * parameter, which is often around 25.
- *
- * MAX_PROC_SEMS is the maximum number of per-process semaphores (those used
- * by the lock mgr) we can keep track of. It must be a multiple of
- * PROC_NSEMS_PER_SET.
- */
-#define PROC_NSEMS_PER_SET 16
-#define MAX_PROC_SEMS (((MAXBACKENDS-1)/PROC_NSEMS_PER_SET+1)*PROC_NSEMS_PER_SET)
-
-typedef struct procglobal
-{
- SHMEM_OFFSET freeProcs;
- IPCKey currKey;
- int32 freeSemMap[MAX_PROC_SEMS / PROC_NSEMS_PER_SET];
-
- /*
- * In each freeSemMap entry, the PROC_NSEMS_PER_SET least-significant
- * bits flag whether individual semaphores are in use, and the next
- * higher bit is set to show that the entire set is allocated.
- */
-} PROC_HDR;
-
extern PROC *MyProc;
#define PROC_INCR_SLOCK(lock) \
@@ -115,16 +85,46 @@ do { \
extern SPINLOCK ProcStructLock;
+
+/*
+ * There is one ProcGlobal struct for the whole installation.
+ *
+ * PROC_NSEMS_PER_SET is the number of semaphores in each sys-V semaphore set
+ * we allocate. It must be no more than 32 (or however many bits in an int
+ * on your machine), or our free-semaphores bitmap won't work. It also must
+ * be *less than* your kernel's SEMMSL (max semaphores per set) parameter,
+ * which is often around 25. (Less than, because we allocate one extra sema
+ * in each set for identification purposes.)
+ *
+ * PROC_SEM_MAP_ENTRIES is the number of semaphore sets we need to allocate
+ * to keep track of up to MAXBACKENDS backends.
+ */
+#define PROC_NSEMS_PER_SET 16
+#define PROC_SEM_MAP_ENTRIES ((MAXBACKENDS-1)/PROC_NSEMS_PER_SET+1)
+
+typedef struct procglobal
+{
+ /* Head of list of free PROC structures */
+ SHMEM_OFFSET freeProcs;
+
+ /* Info about semaphore sets used for per-process semaphores */
+ IpcSemaphoreId procSemIds[PROC_SEM_MAP_ENTRIES];
+ int32 freeSemMap[PROC_SEM_MAP_ENTRIES];
+
+ /*
+ * In each freeSemMap entry, bit i is set if the i'th semaphore of the
+ * set is allocated to a process. (i counts from 0 at the LSB)
+ */
+} PROC_HDR;
+
/*
* Function Prototypes
*/
-extern void InitProcess(IPCKey key);
+extern void InitProcGlobal(int maxBackends);
+extern void InitProcess(void);
extern void ProcReleaseLocks(void);
extern bool ProcRemove(int pid);
-/* extern bool ProcKill(int exitStatus, int pid); */
-/* make static in storage/lmgr/proc.c -- jolly */
-
extern void ProcQueueInit(PROC_QUEUE *queue);
extern int ProcSleep(PROC_QUEUE *queue, LOCKMETHODCTL *lockctl, int token,
LOCK *lock);
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 9f0fd7c68e3..d50e3564bb7 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.73 2000/10/22 22:15:03 petere Exp $
+ * $Header: /cvsroot/pgsql/src/include/storage/s_lock.h,v 1.74 2000/11/28 23:27:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -26,7 +26,7 @@
* void S_LOCK_FREE(slock_t *lock)
* Tests if the lock is free. Returns non-zero if free, 0 if locked.
*
- * The S_LOCK() macro implements a primitive but still useful random
+ * The S_LOCK() macro implements a primitive but still useful random
* backoff to avoid hordes of busywaiting lockers chewing CPU.
*
* Effectively:
@@ -64,7 +64,7 @@
* manual for POWER in any case.
*
*/
-#if !defined(S_LOCK_H)
+#ifndef S_LOCK_H
#define S_LOCK_H
#include "storage/ipc.h"
@@ -403,8 +403,8 @@ extern void s_lock(volatile slock_t *lock, const char *file, const int line);
#define S_LOCK(lock) \
do { \
- if (TAS((volatile slock_t *) lock)) \
- s_lock((volatile slock_t *) lock, __FILE__, __LINE__); \
+ if (TAS((volatile slock_t *) (lock))) \
+ s_lock((volatile slock_t *) (lock), __FILE__, __LINE__); \
} while (0)
#endif /* S_LOCK */
@@ -421,12 +421,46 @@ extern void s_lock(volatile slock_t *lock, const char *file, const int line);
#endif /* S_INIT_LOCK */
#if !defined(TAS)
-int tas(volatile slock_t *lock); /* port/.../tas.s, or
+extern int tas(volatile slock_t *lock); /* port/.../tas.s, or
* s_lock.c */
-#define TAS(lock) tas((volatile slock_t *) lock)
+#define TAS(lock) tas((volatile slock_t *) (lock))
#endif /* TAS */
+
+#else /* !HAS_TEST_AND_SET */
+
+/*
+ * Fake spinlock implementation using SysV semaphores --- slow and prone
+ * to fall foul of kernel limits on number of semaphores, so don't use this
+ * unless you must!
+ */
+
+typedef struct
+{
+ /* reference to semaphore used to implement this spinlock */
+ IpcSemaphoreId semId;
+ int sem;
+} slock_t;
+
+extern bool s_lock_free_sema(volatile slock_t *lock);
+extern void s_unlock_sema(volatile slock_t *lock);
+extern void s_init_lock_sema(volatile slock_t *lock);
+extern int tas_sema(volatile slock_t *lock);
+
+extern void s_lock(volatile slock_t *lock, const char *file, const int line);
+
+#define S_LOCK(lock) \
+ do { \
+ if (TAS((volatile slock_t *) (lock))) \
+ s_lock((volatile slock_t *) (lock), __FILE__, __LINE__); \
+ } while (0)
+
+#define S_LOCK_FREE(lock) s_lock_free_sema(lock)
+#define S_UNLOCK(lock) s_unlock_sema(lock)
+#define S_INIT_LOCK(lock) s_init_lock_sema(lock)
+#define TAS(lock) tas_sema(lock)
+
#endif /* HAS_TEST_AND_SET */
-#endif /* S_LOCK_H */
+#endif /* S_LOCK_H */
diff --git a/src/include/storage/shmem.h b/src/include/storage/shmem.h
index 35545f95191..8b2cc4487f0 100644
--- a/src/include/storage/shmem.h
+++ b/src/include/storage/shmem.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: shmem.h,v 1.23 2000/06/28 03:33:27 tgl Exp $
+ * $Id: shmem.h,v 1.24 2000/11/28 23:27:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -18,17 +18,23 @@
#include "utils/hsearch.h"
-/* The shared memory region can start at a different address
+/*
+ * The shared memory region can start at a different address
* in every process. Shared memory "pointers" are actually
* offsets relative to the start of the shared memory region(s).
+ *
+ * In current usage, this is not actually a problem, but we keep
+ * the code that used to handle it...
*/
typedef unsigned long SHMEM_OFFSET;
#define INVALID_OFFSET (-1)
#define BAD_LOCATION (-1)
-/* start of the lowest shared memory region. For now, assume that
- * there is only one shared memory region
+/*
+ * Start of the primary shared memory region, in this process' address space.
+ * The macros in this header file can only cope with offsets into this
+ * shared memory region!
*/
extern SHMEM_OFFSET ShmemBase;
@@ -39,14 +45,14 @@ extern SHMEM_OFFSET ShmemBase;
/* coerce a pointer into a shmem offset */
#define MAKE_OFFSET(xx_ptr)\
- (SHMEM_OFFSET) (((unsigned long)(xx_ptr))-ShmemBase)
+ ((SHMEM_OFFSET) (((unsigned long)(xx_ptr))-ShmemBase))
#define SHM_PTR_VALID(xx_ptr)\
- (((unsigned long)xx_ptr) > ShmemBase)
+ (((unsigned long)(xx_ptr)) > ShmemBase)
/* cannot have an offset to ShmemFreeStart (offset 0) */
#define SHM_OFFSET_VALID(xx_offs)\
- ((xx_offs != 0) && (xx_offs != INVALID_OFFSET))
+ (((xx_offs) != 0) && ((xx_offs) != INVALID_OFFSET))
extern SPINLOCK ShmemLock;
@@ -60,11 +66,9 @@ typedef struct SHM_QUEUE
} SHM_QUEUE;
/* shmem.c */
-extern void ShmemIndexReset(void);
-extern void ShmemCreate(unsigned int key, unsigned int size);
-extern int InitShmem(unsigned int key, unsigned int size);
+extern void InitShmemAllocation(PGShmemHeader *seghdr);
extern void *ShmemAlloc(Size size);
-extern int ShmemIsValid(unsigned long addr);
+extern bool ShmemIsValid(unsigned long addr);
extern HTAB *ShmemInitHash(char *name, long init_size, long max_size,
HASHCTL *infoP, int hash_flags);
extern bool ShmemPIDLookup(int pid, SHMEM_OFFSET *locationPtr);
diff --git a/src/include/storage/sinval.h b/src/include/storage/sinval.h
index 4c80f760faa..1cadb54fd24 100644
--- a/src/include/storage/sinval.h
+++ b/src/include/storage/sinval.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sinval.h,v 1.15 2000/11/12 20:51:52 tgl Exp $
+ * $Id: sinval.h,v 1.16 2000/11/28 23:27:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,9 +19,9 @@
extern SPINLOCK SInvalLock;
-extern void CreateSharedInvalidationState(IPCKey key, int maxBackends);
-extern void AttachSharedInvalidationState(IPCKey key);
-extern void InitSharedInvalidationState(void);
+extern int SInvalShmemSize(int maxBackends);
+extern void CreateSharedInvalidationState(int maxBackends);
+extern void InitBackendSharedInvalidationState(void);
extern void RegisterSharedInvalid(int cacheId, Index hashIndex,
ItemPointer pointer);
extern void InvalidateSharedInvalid(void (*invalFunction) (),
diff --git a/src/include/storage/sinvaladt.h b/src/include/storage/sinvaladt.h
index b9704d34e4d..c31caf53bf5 100644
--- a/src/include/storage/sinvaladt.h
+++ b/src/include/storage/sinvaladt.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: sinvaladt.h,v 1.23 2000/11/12 20:51:52 tgl Exp $
+ * $Id: sinvaladt.h,v 1.24 2000/11/28 23:27:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -107,15 +107,13 @@ typedef struct SISeg
} SISeg;
-extern SISeg *shmInvalBuffer; /* pointer to the shared buffer segment,
- * set by SISegmentAttach() */
+extern SISeg *shmInvalBuffer; /* pointer to the shared inval buffer */
/*
* prototypes for functions in sinvaladt.c
*/
-extern int SISegmentInit(bool createNewSegment, IPCKey key,
- int maxBackends);
+extern void SIBufferInit(int maxBackends);
extern int SIBackendInit(SISeg *segP);
extern bool SIInsertDataEntry(SISeg *segP, SharedInvalidData *data);
diff --git a/src/include/storage/spin.h b/src/include/storage/spin.h
index 656e1097a23..53efabcadb1 100644
--- a/src/include/storage/spin.h
+++ b/src/include/storage/spin.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: spin.h,v 1.12 2000/05/31 00:28:38 petere Exp $
+ * $Id: spin.h,v 1.13 2000/11/28 23:27:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,11 +19,10 @@
/*
* two implementations of spin locks
*
- * sequent, sparc, sun3: real spin locks. uses a TAS instruction; see
- * src/storage/ipc/s_lock.c for details.
- *
- * default: fake spin locks using semaphores. see spin.c
+ * Where TAS instruction is available: real spin locks.
+ * See src/storage/ipc/s_lock.c for details.
*
+ * Otherwise: fake spin locks using semaphores. see spin.c
*/
typedef int SPINLOCK;
@@ -32,8 +31,10 @@ typedef int SPINLOCK;
extern bool Trace_spinlocks;
#endif
-extern void CreateSpinlocks(IPCKey key);
-extern void InitSpinLocks(void);
+
+extern int SLockShmemSize(void);
+extern void CreateSpinlocks(PGShmemHeader *seghdr);
+
extern void SpinAcquire(SPINLOCK lockid);
extern void SpinRelease(SPINLOCK lockid);