1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

VariableCache (next XID generator) is placed in shmem.

This commit is contained in:
Vadim B. Mikheev
1998-07-21 06:17:39 +00:00
parent 224a62c5b7
commit 5afe171443
3 changed files with 50 additions and 73 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.27 1998/06/30 19:09:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.28 1998/07/21 06:17:35 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@@ -67,6 +67,8 @@
#include "storage/proc.h"
#include "utils/dynahash.h"
#include "utils/hsearch.h"
#include "utils/memutils.h"
#include "access/transam.h"
/* shared memory global variables */
@@ -74,6 +76,8 @@ unsigned long ShmemBase = 0; /* start and end address of shared memory */
static unsigned long ShmemEnd = 0;
static unsigned long ShmemSize = 0; /* current size (and default) */
extern VariableCache ShmemVariableCache; /* varsup.c */
SPINLOCK ShmemLock; /* lock for shared memory allocation */
SPINLOCK ShmemIndexLock; /* lock for shmem index access */
@@ -151,7 +155,6 @@ InitShmem(unsigned int key, unsigned int size)
item;
bool found;
IpcMemoryId shmid;
/* if zero key, use default memory size */
if (size)
ShmemSize = size;
@@ -180,9 +183,12 @@ InitShmem(unsigned int key, unsigned int size)
ShmemFreeStart = (unsigned long *) ShmemBase;
/* next is a shmem pointer to the shmem index */
ShmemIndexOffset = ShmemFreeStart + 1;
/* next is ShmemVariableCache */
ShmemVariableCache = (VariableCache) (ShmemIndexOffset + 1);
currFreeSpace +=
sizeof(ShmemFreeStart) + sizeof(ShmemIndexOffset);
sizeof(ShmemFreeStart) + sizeof(ShmemIndexOffset) +
LONGALIGN(sizeof(VariableCacheData));
/*
* bootstrap initialize spin locks so we can start to use the
@@ -196,7 +202,10 @@ InitShmem(unsigned int key, unsigned int size)
* setup the global free space count
*/
if (ShmemBootstrap)
{
*ShmemFreeStart = currFreeSpace;
memset (ShmemVariableCache, 0, sizeof(*ShmemVariableCache));
}
/* if ShmemFreeStart is NULL, then the allocator won't work */
Assert(*ShmemFreeStart);