head 1.24; access; symbols release_4_2:1.24 aix_ok:1.23 Version_2_1:1.13 old_buffer_manager:1.9 no_dilllon_crap:1.5 C_Demo_1:1.4; locks; strict; comment @ * @; 1.24 date 94.02.07.11.44.41; author aoki; state Exp; branches; next 1.23; 1.23 date 93.08.24.05.34.49; author aoki; state Exp; branches; next 1.22; 1.22 date 91.08.29.23.54.07; author mer; state Exp; branches; next 1.21; 1.21 date 91.08.14.12.33.24; author mer; state Exp; branches; next 1.20; 1.20 date 91.08.13.21.59.58; author mao; state Exp; branches; next 1.19; 1.19 date 91.08.11.16.37.01; author mer; state Exp; branches; next 1.18; 1.18 date 91.07.24.07.46.49; author mao; state Exp; branches; next 1.17; 1.17 date 91.07.22.22.21.16; author mao; state Exp; branches; next 1.16; 1.16 date 91.07.22.14.31.08; author mer; state Exp; branches; next 1.15; 1.15 date 91.07.17.23.46.14; author hong; state Exp; branches; next 1.14; 1.14 date 91.06.10.20.57.46; author kemnitz; state Exp; branches; next 1.13; 1.13 date 91.02.21.10.56.14; author hong; state Exp; branches; next 1.12; 1.12 date 91.02.18.20.40.27; author hong; state Exp; branches; next 1.11; 1.11 date 91.01.25.13.58.24; author hong; state Exp; branches; next 1.10; 1.10 date 91.01.18.22.16.24; author hong; state Exp; branches; next 1.9; 1.9 date 90.10.23.17.19.41; author kemnitz; state Exp; branches; next 1.8; 1.8 date 90.10.16.23.33.24; author hong; state Exp; branches; next 1.7; 1.7 date 90.09.25.17.06.45; author kemnitz; state Exp; branches; next 1.6; 1.6 date 90.03.01.15.40.14; author cimarron; state Exp; branches; next 1.5; 1.5 date 90.02.01.17.39.24; author goh; state Exp; branches; next 1.4; 1.4 date 89.09.05.17.23.39; author mao; state C_Demo_1; branches; next 1.3; 1.3 date 89.08.03.00.06.20; author dillon; state Exp; branches; next 1.2; 1.2 date 89.02.02.16.16.01; author dillon; state Stab; branches; next 1.1; 1.1 date 89.01.17.05.57.20; author cimarron; state Exp; branches; next ; desc @@ 1.24 log @ipc.h protos require ipci.h but someone included them backwards all over the storage directory.. @ text @/* * ipci.c -- * POSTGRES inter-process communication initialization code. */ #include "tmp/c.h" #include "storage/ipci.h" #include "storage/ipc.h" #include "utils/log.h" #include "storage/sinval.h" #include "storage/bufmgr.h" #include "storage/lock.h" #include "tcop/slaves.h" #include "tmp/miscadmin.h" /* for DebugLvl */ RcsId("$Header: /faerie/aoki/postgres/src/backend/storage/ipc/RCS/ipci.c,v 1.23 1993/08/24 05:34:49 aoki Exp aoki $"); IPCKey SystemPortAddressCreateIPCKey(address) SystemPortAddress address; { Assert(address < 32768); /* XXX */ return (SystemPortAddressGetIPCKey(address)); } /************************************************** CreateSharedMemoryAndSemaphores is called exactly *ONCE* by the postmaster. It is *NEVER* called by the postgres backend 0) destroy any existing semaphores for both buffer and lock managers. 1) create the appropriate *SHARED* memory segments for the two resource managers. **************************************************/ void CreateSharedMemoryAndSemaphores(key) IPCKey key; { int status; int size; #ifdef HAS_TEST_AND_SET /* --------------- * create shared memory for slocks * -------------- */ CreateAndInitSLockMemory(IPCKeyGetSLockSharedMemoryKey(key)); #endif /* ---------------- * kill and create the buffer manager buffer pool (and semaphore) * ---------------- */ CreateSpinlocks(IPCKeyGetSpinLockSemaphoreKey(key)); size = BufferShmemSize() + LockShmemSize(); #ifdef SONY_JUKEBOX size += SJShmemSize(); #endif /* SONY_JUKEBOX */ #ifdef MAIN_MEMORY size += MMShmemSize(); #endif /* MAIN_MEMORY */ if (DebugLvl > 1) { fprintf(stderr, "binding ShmemCreate(key=%x, size=%d)\n", IPCKeyGetBufferMemoryKey(key), size); } ShmemCreate(IPCKeyGetBufferMemoryKey(key), size); ShmemBindingTabReset(); InitShmem(key, size); InitBufferPool(key); /* ---------------- * create and initialize the executor shared segment (and semaphore) * ---------------- */ if (key == PrivateIPCKey && ParallelExecutorEnabled()) { ExecInitExecutorSemaphore(PrivateIPCKey); ExecCreateExecutorSharedMemory(PrivateIPCKey); ExecAttachExecutorSharedMemory(); } #ifdef SONY_JUKEBOX /* ---------------- * create and initialize the sony jukebox shared semaphore * ---------------- */ SJInitSemaphore(key); #endif /* ---------------- * do the lock table stuff * ---------------- */ InitLocks(); InitMultiLevelLockm(); if (InitMultiLevelLockm() == INVALID_TABLEID) elog(FATAL, "Couldn't create the lock table"); CreateSharedInvalidationState(key); } void AttachSharedMemoryAndSemaphores(key) IPCKey key; { int status; int size; /* ---------------- * create rather than attach if using private key * ---------------- */ if (key == PrivateIPCKey) { CreateSharedMemoryAndSemaphores(key); return; } #ifdef HAS_TEST_AND_SET /* ---------------- * attach the slock shared memory * ---------------- */ AttachSLockMemory(IPCKeyGetSLockSharedMemoryKey(key)); #endif /* ---------------- * attach the buffer manager buffer pool (and semaphore) * ---------------- */ size = BufferShmemSize() + LockShmemSize(); InitShmem(key, size); InitBufferPool(key); /* ---------------- * create and initialize the executor shared segment (and semaphore) * ---------------- */ if (ParallelExecutorEnabled()) { ExecInitExecutorSemaphore(PrivateIPCKey); ExecCreateExecutorSharedMemory(PrivateIPCKey); ExecAttachExecutorSharedMemory(); } #ifdef SONY_JUKEBOX /* ---------------- * create and initialize the sony jukebox shared semaphore * ---------------- */ SJInitSemaphore(key); #endif /* ---------------- * initialize lock table stuff * ---------------- */ InitLocks(); if (InitMultiLevelLockm() == INVALID_TABLEID) elog(FATAL, "Couldn't attach to the lock table"); AttachSharedInvalidationState(key); } @ 1.23 log @added a debugging printf @ text @d8 1 a11 1 #include "storage/ipci.h" d17 1 a17 1 RcsId("$Header: /home2/aoki/postgres/src/backend/storage/ipc/RCS/ipci.c,v 1.22 1991/08/29 23:54:07 mer Exp aoki $"); @ 1.22 log @purge old lmgr code @ text @d15 1 d17 1 a17 1 RcsId("$Header: /users/mer/postgres/src/storage/ipc/RCS/ipci.c,v 1.21 1991/08/14 12:33:24 mer Exp mer $"); d70 4 @ 1.21 log @add call to reset binding table for reinitting shared memory @ text @a9 1 #include "storage/pladt.h" d16 1 a16 4 RcsId("$Header: RCS/ipci.c,v 1.20 91/08/13 21:59:58 mao Exp Locker: mer $"); LockTableId PageLockTableId; LockTableId MultiLevelLockTableId; @ 1.20 log @init jukebox lock here, so that postmaster can find it on shutdown @ text @d17 1 a17 1 RcsId("$Header: /local/mao/postgres/src/storage/ipc/RCS/ipci.c,v 1.19 1991/08/11 16:37:01 mer Exp $"); d74 1 @ 1.19 log @move InitProcess() to InitPostgres() @ text @d17 1 a17 1 RcsId("$Header: RCS/ipci.c,v 1.18 91/07/24 07:46:49 mao Exp $"); d86 9 a94 1 d148 8 @ 1.18 log @cleanup and add main memory storage manager @ text @d14 1 d17 1 a17 1 RcsId("$Header: /users/mao/postgres/src/storage/ipc/RCS/ipci.c,v 1.17 1991/07/22 22:21:16 mao Exp mao $"); d93 2 a94 1 InitProcess(key); d146 2 a147 2 InitMultiLevelLockm(); InitProcess(key); @ 1.17 log @jukebox storage manager installation @ text @d16 1 a16 1 RcsId("$Header: /users/mao/postgres/src/storage/ipc/RCS/ipci.c,v 1.16 1991/07/22 14:31:08 mer Exp mao $"); d62 2 d65 1 a65 3 size = BufferShmemSize() + LockShmemSize() + SJShmemSize(); #else /* SONY_JUKEBOX */ size = BufferShmemSize() + LockShmemSize(); d67 5 @ 1.16 log @modify initialization routines for new lock manager. @ text @d16 1 a16 1 RcsId("$Header: RCS/ipci.c,v 1.15 91/07/17 23:46:14 hong Exp Locker: mer $"); d62 3 d66 1 @ 1.15 log @include slaves.h to get rid of some compile warnings @ text @d16 1 a16 1 RcsId("$Header: RCS/ipci.c,v 1.14 91/06/10 20:57:46 kemnitz Exp Locker: hong $"); a49 7 /* ---------------- * kill the lock table stuff * ---------------- */ LtSynchKill(IPCKeyGetLockTableMemoryKey(key)); LtTransactionSemaphoreKill(IPCKeyGetLockTableSemaphoreKey(key)); d62 1 a62 1 size = BufferShmemSize(); d81 3 a83 2 LtSynchInit(IPCKeyGetLockTableMemoryKey(key)); LtTransactionSemaphoreInit(IPCKeyGetLockTableSemaphoreKey(key)); a84 13 status = LMSegmentInit(true, IPCKeyGetLockTableSemaphoreBlockKey(key)); if (status == -1) elog(FATAL, "CreateSharedMemoryAndSemaphores: failed LMSegmentInit"); PageLockTableId = LMLockTableCreate("page", PageLockTable, LockTableNormal); MultiLevelLockTableId = LMLockTableCreate("multiLevel", MultiLevelLockTable, LockTableNormal); d116 1 a116 1 size = BufferShmemSize(); d134 3 a136 15 LtSynchInit(IPCKeyGetLockTableMemoryKey(key)); LtTransactionSemaphoreInit(IPCKeyGetLockTableSemaphoreKey(key)); status = LMSegmentInit(false, IPCKeyGetLockTableSemaphoreBlockKey(key)); if (status == -1) elog(FATAL, "AttachSharedMemoryAndSemaphores: failed LMSegmentInit"); PageLockTableId = LMLockTableCreate("page", PageLockTable, LockTableNormal); MultiLevelLockTableId = LMLockTableCreate("multiLevel", MultiLevelLockTable, LockTableNormal); @ 1.14 log @generalization of spinlocks. @ text @d14 1 d16 1 a16 1 RcsId("$Header: ipc/RCS/ipci.c,v 1.13 91/02/21 10:56:14 hong Exp Locker: kemnitz $"); @ 1.13 log @forgot to allocate shared memory for parallel backends when not running under postmaster. @ text @d15 1 a15 1 RcsId("$Header: RCS/ipci.c,v 1.12 91/02/18 20:40:27 hong Exp Locker: hong $"); d56 1 a56 1 #ifdef sequent d123 1 a123 1 #ifdef sequent @ 1.12 log @Executor shared memory always has PrivateIPCKey it is not supposed to be shared with another postgres backend group under the same postmaster. @ text @d15 1 a15 1 RcsId("$Header: RCS/ipci.c,v 1.11 91/01/25 13:58:24 hong Exp Locker: hong $"); d72 10 @ 1.11 log @to allow variable buffer pool size @ text @d15 1 a15 1 RcsId("$Header: RCS/ipci.c,v 1.10 91/01/18 22:16:24 hong Exp $"); a71 8 /* ---------------- * create and initialize the executor shared segment (and semaphore) * ---------------- */ if (ParallelExecutorEnabled()) { IpcSemaphoreKill(IPCKeyGetExecutorSemaphoreKey(key)); ExecInitExecutorSemaphore(IPCKeyGetExecutorSemaphoreKey(key)); a72 5 IpcMemoryKill(IPCKeyGetExecutorSharedMemoryKey(key)); ExecCreateExecutorSharedMemory(IPCKeyGetExecutorSharedMemoryKey(key)); ExecAttachExecutorSharedMemory(); } d129 1 a129 1 * attach the parallel executor memory (and semaphore) d133 2 a134 2 ExecInitExecutorSemaphore(IPCKeyGetExecutorSemaphoreKey(key)); ExecLocateExecutorSharedMemory(IPCKeyGetExecutorSharedMemoryKey(key)); d137 1 a137 1 @ 1.10 log @changed initialization code for the new buffer manager @ text @a11 1 d13 1 d15 1 a15 1 RcsId("$Header: RCS/ipci.c,v 1.9 90/10/23 17:19:41 kemnitz Exp $"); d47 1 d68 3 a70 2 ShmemCreate(IPCKeyGetBufferMemoryKey(key), 0); InitShmem(key, 0); d115 1 d137 2 a138 1 InitShmem(key, 0); @ 1.9 log @fixed problem with SLocks on sequent when postmaster is run @ text @d15 1 a15 1 RcsId("$Header: RCS/ipci.c,v 1.8 90/10/16 23:33:24 hong Exp $"); d66 4 a69 2 CreateBufferSemaphore(IPCKeyGetBufferSemaphoreKey(key)); CreateBufferPoolMemory(IPCKeyGetBufferMemoryKey(key)); d134 2 a135 3 InitBufferSemaphore(IPCKeyGetBufferSemaphoreKey(key)); InitBufferPoolMemory(IPCKeyGetBufferMemoryKey(key), false); AttachSharedBuffers(IPCKeyGetBufferMemoryKey(key)); @ 1.8 log @replace semaphores with hardware locks for sequent @ text @d15 1 a15 1 RcsId("$Header: RCS/ipci.c,v 1.7 90/09/25 17:06:45 kemnitz Exp Locker: hong $"); d126 1 a126 1 AttachSLockMemory(); @ 1.7 log @Updating from revision 1.6 to revision 1.7 @ text @d15 1 a15 1 RcsId("$Header: RCS/ipci.c,v 1.7 90/08/17 13:59:17 cimarron Exp $"); d55 7 d121 7 @ 1.6 log @general changes to add parallelism support, in-memory relations, and various code cleanups. @ text @d6 1 a6 1 #include "c.h" d8 4 a11 4 #include "ipc.h" #include "log.h" #include "pladt.h" #include "sinval.h" d13 1 a13 1 #include "ipci.h" d15 1 a15 1 RcsId("$Header: RCS/ipci.c,v 1.5 90/02/01 17:39:24 goh Exp $"); @ 1.5 log @no dillon wierd locks @ text @d15 1 a15 1 RcsId("$Header: RCS/ipci.c,v 1.2 89/02/02 16:16:01 dillon Stab $"); d44 1 a44 1 IPCKey key; d46 1 a46 1 int status; d48 6 a53 2 LtSynchKill(IPCKeyGetLockTableMemoryKey(key)); LtTransactionSemaphoreKill(IPCKeyGetLockTableSemaphoreKey(key)); d55 6 a60 3 /* kill and create the buffer manager buffer pool (and semaphore) */ CreateBufferSemaphore(IPCKeyGetBufferSemaphoreKey(key)); CreateBufferPoolMemory(IPCKeyGetBufferMemoryKey(key)); d62 19 a80 2 LtSynchInit(IPCKeyGetLockTableMemoryKey(key)); LtTransactionSemaphoreInit(IPCKeyGetLockTableSemaphoreKey(key)); d82 1 a82 1 status = LMSegmentInit(true, IPCKeyGetLockTableSemaphoreBlockKey(key)); d84 2 a85 3 if (status == -1) { elog(FATAL, "CreateSharedMemory: failed segment init"); } d87 7 a93 4 PageLockTableId = LMLockTableCreate("page", PageLockTable, LockTableNormal); MultiLevelLockTableId = LMLockTableCreate("multiLevel", MultiLevelLockTable, LockTableNormal); d95 1 a95 1 CreateSharedInvalidationState(key); d98 1 d101 1 a101 1 IPCKey key; d103 1 a103 1 int status; d105 8 a112 4 if (key == PrivateIPCKey) { CreateSharedMemoryAndSemaphores(key); return; } d114 7 a120 4 /* attach the buffer manager buffer pool (and semaphore) */ InitBufferSemaphore(IPCKeyGetBufferSemaphoreKey(key)); InitBufferPoolMemory(IPCKeyGetBufferMemoryKey(key), false); AttachSharedBuffers(IPCKeyGetBufferMemoryKey(key)); d122 16 a137 2 LtSynchInit(IPCKeyGetLockTableMemoryKey(key)); LtTransactionSemaphoreInit(IPCKeyGetLockTableSemaphoreKey(key)); d139 1 a139 1 status = LMSegmentInit(false, IPCKeyGetLockTableSemaphoreBlockKey(key)); d141 2 a142 3 if (status == -1) { elog(FATAL, "AttachSharedMemory: failed segment init"); } d144 7 a150 4 PageLockTableId = LMLockTableCreate("page", PageLockTable, LockTableNormal); MultiLevelLockTableId = LMLockTableCreate("multiLevel", MultiLevelLockTable, LockTableNormal); d152 1 a152 1 AttachSharedInvalidationState(key); @ 1.4 log @Working version of C-only demo @ text @d15 1 a15 1 RcsId("$Header: /usr6/postgres/mao/postgres/src/storage/ipc/RCS/ipci.c,v 1.3 89/08/03 00:06:20 dillon Exp $"); a47 1 /* REMOVED d49 1 a49 4 */ /* REMOVED * LtTransactionSemaphoreKill(IPCKeyGetLockTableSemaphoreKey(key)); */ a50 2 status = LMSegmentInit(true, IPCKeyGetLockTableMemoryKey(key)); d52 1 a52 3 /* REMOVED * CreateBufferSemaphore(IPCKeyGetBufferSemaphoreKey(key)); */ a54 1 /* REMOVED d56 1 a56 4 */ /* REMOVED *LtTransactionSemaphoreInit(IPCKeyGetLockTableSemaphoreKey(key)); */ d58 1 d84 1 a84 3 /* REMOVED * InitBufferSemaphore(IPCKeyGetBufferSemaphoreKey(key)); */ d86 1 a87 1 /* REMOVED d89 1 a89 4 */ /* REMOVED * LtTransactionSemaphoreInit(IPCKeyGetLockTableSemaphoreKey(key)); */ d91 1 a91 3 status = LMSegmentInit(false, IPCKeyGetLockTableMemoryKey(key)); AttachSharedBuffers(IPCKeyGetBufferMemoryKey(key)); @ 1.3 log @shared memory lock manager code (does not used semaphores) @ text @d15 1 a15 1 RcsId("$Header: ipci.c,v 1.2 89/02/02 16:16:01 dillon Locked $"); @ 1.2 log @Txfer from old tree @ text @d15 1 a15 1 RcsId("$Header: ipci.c,v 1.5 88/08/16 21:16:55 dillon Locked $"); d48 1 d50 4 a53 1 LtTransactionSemaphoreKill(IPCKeyGetLockTableSemaphoreKey(key)); d55 2 d58 3 a60 1 CreateBufferSemaphore(IPCKeyGetBufferSemaphoreKey(key)); d63 1 d65 4 a68 1 LtTransactionSemaphoreInit(IPCKeyGetLockTableSemaphoreKey(key)); a69 1 status = LMSegmentInit(true, IPCKeyGetLockTableSemaphoreBlockKey(key)); d95 3 a97 1 InitBufferSemaphore(IPCKeyGetBufferSemaphoreKey(key)); a98 1 AttachSharedBuffers(IPCKeyGetBufferMemoryKey(key)); d100 1 d102 4 a105 1 LtTransactionSemaphoreInit(IPCKeyGetLockTableSemaphoreKey(key)); d107 3 a109 1 status = LMSegmentInit(false, IPCKeyGetLockTableSemaphoreBlockKey(key)); @ 1.1 log @Initial revision @ text @a0 1 a1 26 * * POSTGRES Data Base Management System * * Copyright (c) 1988 Regents of the University of California * * Permission to use, copy, modify, and distribute this software and its * documentation for educational, research, and non-profit purposes and * without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, and that * the name of the University of California not be used in advertising * or publicity pertaining to distribution of the software without * specific, written prior permission. Permission to incorporate this * software into commercial products can be obtained from the Campus * Software Office, 295 Evans Hall, University of California, Berkeley, * Ca., 94720 provided only that the the requestor give the University * of California a free licence to any derived software for educational * and research purposes. The University of California makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * */ /* d15 1 a15 1 RcsId("$Header: ipci.c,v 1.1 88/11/11 16:37:38 postgres Exp $"); @