PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
spin.h File Reference
#include "storage/s_lock.h"
#include "storage/pg_sema.h"
Include dependency graph for spin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SpinLockInit(lock)   S_INIT_LOCK(lock)
 
#define SpinLockAcquire(lock)   S_LOCK(lock)
 
#define SpinLockRelease(lock)   S_UNLOCK(lock)
 
#define SpinLockFree(lock)   S_LOCK_FREE(lock)
 

Functions

int SpinlockSemas (void)
 
Size SpinlockSemaSize (void)
 
void SpinlockSemaInit (void)
 

Variables

PGSemaphoreSpinlockSemaArray
 

Macro Definition Documentation

#define SpinLockAcquire (   lock)    S_LOCK(lock)

Definition at line 62 of file spin.h.

Referenced by _bt_parallel_advance_array_keys(), _bt_parallel_done(), _bt_parallel_release(), _bt_parallel_seize(), AbortStrongLockAcquire(), AdvanceXLInsertBuffer(), AuxiliaryProcKill(), BeginStrongLockAcquire(), BitmapAdjustPrefetchIterator(), BitmapAdjustPrefetchTarget(), BitmapDoneInitializingSharedState(), BitmapHeapNext(), BitmapPrefetch(), BitmapShouldInitializeSharedState(), btparallelrescan(), CheckpointerMain(), CheckRecoveryConsistency(), CheckXLogRemoved(), ClockSweepTick(), ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), ConditionVariableSignal(), ConditionVariableSleep(), CreateCheckPoint(), CreateInitDecodingContext(), CreateRestartPoint(), do_pg_start_backup(), do_pg_stop_backup(), element_alloc(), FirstCallSinceLastCheckpoint(), get_hash_entry(), GetCurrentChunkReplayStartTime(), GetFakeLSNForUnloggedRel(), GetFlushRecPtr(), GetInsertRecPtr(), GetLatestXTime(), GetNextXidAndEpoch(), GetOldSnapshotThresholdTimestamp(), GetRedoRecPtr(), GetReplicationApplyDelay(), GetReplicationTransferLatency(), GetSnapshotCurrentTimestamp(), GetWalRcvWriteRecPtr(), GetXLogInsertRecPtr(), GetXLogReplayRecPtr(), GetXLogWriteRecPtr(), hash_search_with_hash_value(), HaveNFreeProcs(), heap_parallelscan_nextpage(), heap_rescan(), HotStandbyActive(), InitAuxiliaryProcess(), InitProcess(), InitWalSenderSlot(), KnownAssignedXidsAdd(), KnownAssignedXidsGetAndSetXmin(), KnownAssignedXidsGetOldestXmin(), KnownAssignedXidsSearch(), lock_twophase_recover(), LockRefindAndRelease(), LogicalConfirmReceivedLocation(), LogicalIncreaseRestartDecodingForSlot(), LogicalIncreaseXminForSlot(), LogicalRepSyncTableStart(), LWLockNewTrancheId(), MaintainOldSnapshotTimeMapping(), need_gc_qtexts(), ParallelWorkerReportLastRecEnd(), pg_atomic_compare_exchange_u32_impl(), pg_atomic_compare_exchange_u64_impl(), pg_atomic_fetch_add_u32_impl(), pg_atomic_fetch_add_u64_impl(), pg_atomic_write_u32_impl(), pg_get_replication_slots(), pg_stat_get_wal_receiver(), pg_stat_get_wal_senders(), pg_stat_statements_internal(), pgss_store(), PhysicalConfirmReceivedLocation(), PhysicalReplicationSlotNewXmin(), process_syncing_tables_for_apply(), process_syncing_tables_for_sync(), ProcessStandbyReplyMessage(), ProcessWalSndrMessage(), ProcKill(), ProcSendSignal(), PublishStartupProcessInformation(), qtext_store(), RecoveryIsPaused(), RecoveryRestartPoint(), RemoveLocalLock(), ReplicationSlotAcquire(), ReplicationSlotCreate(), ReplicationSlotDropPtr(), ReplicationSlotMarkDirty(), ReplicationSlotPersist(), ReplicationSlotRelease(), ReplicationSlotsComputeLogicalRestartLSN(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), ReplicationSlotsCountDBSlots(), ReplicationSlotsDropDBSlots(), RequestCheckpoint(), RequestXLogStreaming(), ReserveXLogInsertLocation(), ReserveXLogSwitch(), SaveSlotToPath(), SetCurrentChunkStartTime(), SetLatestXTime(), SetOldSnapshotThresholdTimestamp(), SetRecoveryPause(), SetWalWriterSleeping(), shm_mq_counterparty_gone(), shm_mq_detach(), shm_mq_get_bytes_read(), shm_mq_get_bytes_written(), shm_mq_get_receiver(), shm_mq_get_sender(), shm_mq_inc_bytes_read(), shm_mq_inc_bytes_written(), shm_mq_notify_receiver(), shm_mq_set_receiver(), shm_mq_set_sender(), shm_mq_wait_internal(), shm_toc_allocate(), shm_toc_freespace(), shm_toc_insert(), ShmemAllocNoError(), ShutdownWalRcv(), SIGetDataEntries(), SIInsertDataEntries(), StartLogicalReplication(), StartReplication(), StartupXLOG(), StrategyFreeBuffer(), StrategyGetBuffer(), StrategyNotifyBgWriter(), StrategySyncStart(), SyncRepGetNthLatestSyncRecPtr(), SyncRepGetOldestSyncRecPtr(), test_shm_mq_main(), TransactionIdLimitedForOldSnapshots(), UpdateLastRemovedPtr(), UpdateMinRecoveryPoint(), wait_for_workers_to_become_ready(), WaitXLogInsertionsToFinish(), WalRcvDie(), WalRcvRunning(), WalRcvStreaming(), WalRcvWaitForStartPosition(), WalReceiverMain(), WalSndKill(), WalSndRqstFileReload(), WalSndSetState(), WalSndWakeup(), xlog_redo(), XLogBackgroundFlush(), XLogFlush(), XLogGetLastRemovedSegno(), XLogGetReplicationSlotMinimumLSN(), XLogInsertRecord(), XLogNeedsFlush(), XLogRead(), XLogSendLogical(), XLogSendPhysical(), XLogSetAsyncXactLSN(), XLogSetReplicationSlotMinimumLSN(), XLogWalRcvFlush(), and XLogWrite().

#define SpinLockFree (   lock)    S_LOCK_FREE(lock)

Definition at line 66 of file spin.h.

#define SpinLockRelease (   lock)    S_UNLOCK(lock)

Definition at line 64 of file spin.h.

Referenced by _bt_parallel_advance_array_keys(), _bt_parallel_done(), _bt_parallel_release(), _bt_parallel_seize(), AbortStrongLockAcquire(), AdvanceXLInsertBuffer(), AuxiliaryProcKill(), BeginStrongLockAcquire(), BitmapAdjustPrefetchIterator(), BitmapAdjustPrefetchTarget(), BitmapDoneInitializingSharedState(), BitmapHeapNext(), BitmapPrefetch(), BitmapShouldInitializeSharedState(), btparallelrescan(), CheckpointerMain(), CheckRecoveryConsistency(), CheckXLogRemoved(), ClockSweepTick(), ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), ConditionVariableSignal(), ConditionVariableSleep(), CreateCheckPoint(), CreateInitDecodingContext(), CreateRestartPoint(), do_pg_start_backup(), do_pg_stop_backup(), element_alloc(), FirstCallSinceLastCheckpoint(), get_hash_entry(), GetCurrentChunkReplayStartTime(), GetFakeLSNForUnloggedRel(), GetFlushRecPtr(), GetInsertRecPtr(), GetLatestXTime(), GetNextXidAndEpoch(), GetOldSnapshotThresholdTimestamp(), GetRedoRecPtr(), GetReplicationApplyDelay(), GetReplicationTransferLatency(), GetSnapshotCurrentTimestamp(), GetWalRcvWriteRecPtr(), GetXLogInsertRecPtr(), GetXLogReplayRecPtr(), GetXLogWriteRecPtr(), hash_search_with_hash_value(), HaveNFreeProcs(), heap_parallelscan_nextpage(), heap_rescan(), HotStandbyActive(), InitAuxiliaryProcess(), InitProcess(), InitWalSenderSlot(), KnownAssignedXidsAdd(), KnownAssignedXidsGetAndSetXmin(), KnownAssignedXidsGetOldestXmin(), KnownAssignedXidsSearch(), lock_twophase_recover(), LockRefindAndRelease(), LogicalConfirmReceivedLocation(), LogicalIncreaseRestartDecodingForSlot(), LogicalIncreaseXminForSlot(), LogicalRepSyncTableStart(), LWLockNewTrancheId(), MaintainOldSnapshotTimeMapping(), need_gc_qtexts(), ParallelWorkerReportLastRecEnd(), pg_atomic_compare_exchange_u32_impl(), pg_atomic_compare_exchange_u64_impl(), pg_atomic_fetch_add_u32_impl(), pg_atomic_fetch_add_u64_impl(), pg_atomic_write_u32_impl(), pg_get_replication_slots(), pg_stat_get_wal_receiver(), pg_stat_get_wal_senders(), pg_stat_statements_internal(), pgss_store(), PhysicalConfirmReceivedLocation(), PhysicalReplicationSlotNewXmin(), process_syncing_tables_for_apply(), process_syncing_tables_for_sync(), ProcessStandbyReplyMessage(), ProcessWalSndrMessage(), ProcKill(), ProcSendSignal(), PublishStartupProcessInformation(), qtext_store(), RecoveryIsPaused(), RecoveryRestartPoint(), RemoveLocalLock(), ReplicationSlotAcquire(), ReplicationSlotCreate(), ReplicationSlotDropPtr(), ReplicationSlotMarkDirty(), ReplicationSlotPersist(), ReplicationSlotRelease(), ReplicationSlotsComputeLogicalRestartLSN(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), ReplicationSlotsCountDBSlots(), ReplicationSlotsDropDBSlots(), RequestCheckpoint(), RequestXLogStreaming(), ReserveXLogInsertLocation(), ReserveXLogSwitch(), SaveSlotToPath(), SetCurrentChunkStartTime(), SetLatestXTime(), SetOldSnapshotThresholdTimestamp(), SetRecoveryPause(), SetWalWriterSleeping(), shm_mq_counterparty_gone(), shm_mq_detach(), shm_mq_get_bytes_read(), shm_mq_get_bytes_written(), shm_mq_get_receiver(), shm_mq_get_sender(), shm_mq_inc_bytes_read(), shm_mq_inc_bytes_written(), shm_mq_notify_receiver(), shm_mq_set_receiver(), shm_mq_set_sender(), shm_mq_wait_internal(), shm_toc_allocate(), shm_toc_freespace(), shm_toc_insert(), ShmemAllocNoError(), ShutdownWalRcv(), SIGetDataEntries(), SIInsertDataEntries(), StartLogicalReplication(), StartReplication(), StartupXLOG(), StrategyFreeBuffer(), StrategyGetBuffer(), StrategyNotifyBgWriter(), StrategySyncStart(), SyncRepGetNthLatestSyncRecPtr(), SyncRepGetOldestSyncRecPtr(), test_shm_mq_main(), TransactionIdLimitedForOldSnapshots(), UpdateLastRemovedPtr(), UpdateMinRecoveryPoint(), wait_for_workers_to_become_ready(), WaitXLogInsertionsToFinish(), WalRcvDie(), WalRcvRunning(), WalRcvStreaming(), WalRcvWaitForStartPosition(), WalReceiverMain(), WalSndKill(), WalSndRqstFileReload(), WalSndSetState(), WalSndWakeup(), xlog_redo(), XLogBackgroundFlush(), XLogFlush(), XLogGetLastRemovedSegno(), XLogGetReplicationSlotMinimumLSN(), XLogInsertRecord(), XLogNeedsFlush(), XLogRead(), XLogSendLogical(), XLogSendPhysical(), XLogSetAsyncXactLSN(), XLogSetReplicationSlotMinimumLSN(), XLogWalRcvFlush(), and XLogWrite().

Function Documentation

void SpinlockSemaInit ( void  )

Definition at line 76 of file spin.c.

References i, PGSemaphoreCreate(), ShmemAllocUnlocked(), SpinlockSemas(), and SpinlockSemaSize().

Referenced by CreateSharedMemoryAndSemaphores().

77 {
78  PGSemaphore *spinsemas;
79  int nsemas = SpinlockSemas();
80  int i;
81 
82  /*
83  * We must use ShmemAllocUnlocked(), since the spinlock protecting
84  * ShmemAlloc() obviously can't be ready yet.
85  */
87  for (i = 0; i < nsemas; ++i)
88  spinsemas[i] = PGSemaphoreCreate();
89  SpinlockSemaArray = spinsemas;
90 }
Size SpinlockSemaSize(void)
Definition: spin.c:39
PGSemaphore PGSemaphoreCreate(void)
Definition: posix_sema.c:245
int SpinlockSemas(void)
Definition: spin.c:65
void * ShmemAllocUnlocked(Size size)
Definition: shmem.c:227
int i
PGSemaphore * SpinlockSemaArray
Definition: spin.c:31
int SpinlockSemas ( void  )

Definition at line 65 of file spin.c.

References NUM_ATOMICS_SEMAPHORES, and NUM_SPINLOCK_SEMAPHORES.

Referenced by CreateSharedMemoryAndSemaphores(), SpinlockSemaInit(), and SpinlockSemaSize().

66 {
68 }
#define NUM_ATOMICS_SEMAPHORES
#define NUM_SPINLOCK_SEMAPHORES
Size SpinlockSemaSize ( void  )

Definition at line 39 of file spin.c.

References SpinlockSemas().

Referenced by CreateSharedMemoryAndSemaphores(), and SpinlockSemaInit().

40 {
41  return SpinlockSemas() * sizeof(PGSemaphore);
42 }
int SpinlockSemas(void)
Definition: spin.c:65
struct PGSemaphoreData * PGSemaphore
Definition: pg_sema.h:34

Variable Documentation

PGSemaphore* SpinlockSemaArray

Definition at line 31 of file spin.c.