PostgreSQL Source Code  git master
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

◆ SpinLockAcquire

#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_heapscan(), _bt_parallel_release(), _bt_parallel_scan_and_sort(), _bt_parallel_seize(), AbortStrongLockAcquire(), AdvanceXLInsertBuffer(), AuxiliaryProcKill(), BarrierArriveAndWait(), BarrierAttach(), BarrierDetachImpl(), BarrierParticipants(), BeginStrongLockAcquire(), BitmapAdjustPrefetchIterator(), BitmapAdjustPrefetchTarget(), BitmapDoneInitializingSharedState(), BitmapHeapNext(), BitmapPrefetch(), BitmapShouldInitializeSharedState(), btparallelrescan(), CheckpointerMain(), CheckRecoveryConsistency(), CheckXLogRemoved(), ClockSweepTick(), ConditionVariableBroadcast(), ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), ConditionVariableSignal(), ConditionVariableTimedSleep(), copy_replication_slot(), CreateCheckPoint(), CreateInitDecodingContext(), CreateRestartPoint(), DecodingContextFindStartpoint(), do_pg_start_backup(), do_pg_stop_backup(), element_alloc(), FirstCallSinceLastCheckpoint(), get_hash_entry(), GetCurrentChunkReplayStartTime(), GetFakeLSNForUnloggedRel(), GetFlushRecPtr(), GetInsertRecPtr(), GetLatestXTime(), GetOldSnapshotThresholdTimestamp(), GetRecoveryState(), GetRedoRecPtr(), GetReplicationApplyDelay(), GetReplicationTransferLatency(), GetSnapshotCurrentTimestamp(), GetWalRcvFlushRecPtr(), GetXLogInsertRecPtr(), GetXLogReplayRecPtr(), GetXLogWriteRecPtr(), hash_search_with_hash_value(), HaveNFreeProcs(), HotStandbyActive(), InitAuxiliaryProcess(), InitProcess(), InitWalSenderSlot(), InvalidateObsoleteReplicationSlots(), KnownAssignedXidsAdd(), KnownAssignedXidsGetAndSetXmin(), KnownAssignedXidsGetOldestXmin(), KnownAssignedXidsSearch(), leader_takeover_tapes(), lock_twophase_recover(), LockRefindAndRelease(), LogicalConfirmReceivedLocation(), LogicalIncreaseRestartDecodingForSlot(), LogicalIncreaseXminForSlot(), LogicalRepSyncTableStart(), LWLockNewTrancheId(), MaintainOldSnapshotTimeMapping(), need_gc_qtexts(), ParallelWorkerReportLastRecEnd(), pg_atomic_clear_flag_impl(), 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_test_set_flag_impl(), pg_atomic_write_u32_impl(), pg_get_replication_slots(), pg_physical_replication_slot_advance(), 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(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyReplyMessage(), ProcessWalSndrMessage(), ProcKill(), ProcSendSignal(), PromoteIsTriggered(), PublishStartupProcessInformation(), qtext_store(), ReadRecord(), RecoveryIsPaused(), RecoveryRestartPoint(), RemoveLocalLock(), ReplicationSlotAcquireInternal(), ReplicationSlotCleanup(), ReplicationSlotCreate(), ReplicationSlotDropPtr(), ReplicationSlotMarkDirty(), ReplicationSlotPersist(), ReplicationSlotRelease(), ReplicationSlotReserveWal(), ReplicationSlotsComputeLogicalRestartLSN(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), ReplicationSlotsCountDBSlots(), ReplicationSlotsDropDBSlots(), RequestCheckpoint(), RequestXLogStreaming(), ReserveXLogInsertLocation(), ReserveXLogSwitch(), SaveSlotToPath(), SetCurrentChunkStartTime(), SetLatestXTime(), SetOldSnapshotThresholdTimestamp(), SetPromoteIsTriggered(), SetRecoveryPause(), SetWalWriterSleeping(), SharedFileSetAttach(), SharedFileSetOnDetach(), shm_mq_detach_internal(), shm_mq_get_receiver(), shm_mq_get_sender(), shm_mq_sendv(), shm_mq_set_receiver(), shm_mq_set_sender(), shm_mq_wait_internal(), shm_toc_allocate(), shm_toc_freespace(), shm_toc_insert(), ShmemAllocRaw(), ShutdownWalRcv(), SIGetDataEntries(), SIInsertDataEntries(), SnapshotTooOldMagicForTest(), StartLogicalReplication(), StartReplication(), StartupXLOG(), StrategyFreeBuffer(), StrategyGetBuffer(), StrategyNotifyBgWriter(), StrategySyncStart(), SyncRepGetCandidateStandbys(), SyncRepInitConfig(), table_block_parallelscan_startblock_init(), test_atomic_spin_nest(), test_shm_mq_main(), test_spinlock(), TransactionIdLimitedForOldSnapshots(), UpdateLastRemovedPtr(), UpdateMinRecoveryPoint(), wait_for_workers_to_become_ready(), WaitXLogInsertionsToFinish(), WalRcvDie(), WalRcvForceReply(), WalRcvRunning(), WalRcvStreaming(), WalRcvWaitForStartPosition(), WalReceiverMain(), WalSndInitStopping(), WalSndKill(), WalSndRqstFileReload(), WalSndSetState(), WalSndWaitStopping(), WalSndWakeup(), worker_freeze_result_tape(), worker_get_identifier(), xlog_redo(), XLogBackgroundFlush(), XLogFlush(), XLogGetLastRemovedSegno(), XLogGetReplicationSlotMinimumLSN(), XLogInsertRecord(), XLogNeedsFlush(), XLogSendLogical(), XLogSendPhysical(), XLogSetAsyncXactLSN(), XLogSetReplicationSlotMinimumLSN(), XLogWalRcvFlush(), and XLogWrite().

◆ SpinLockFree

#define SpinLockFree (   lock)    S_LOCK_FREE(lock)

Definition at line 66 of file spin.h.

◆ SpinLockInit

◆ SpinLockRelease

#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_heapscan(), _bt_parallel_release(), _bt_parallel_scan_and_sort(), _bt_parallel_seize(), AbortStrongLockAcquire(), AdvanceXLInsertBuffer(), AuxiliaryProcKill(), BarrierArriveAndWait(), BarrierAttach(), BarrierDetachImpl(), BarrierParticipants(), BeginStrongLockAcquire(), BitmapAdjustPrefetchIterator(), BitmapAdjustPrefetchTarget(), BitmapDoneInitializingSharedState(), BitmapHeapNext(), BitmapPrefetch(), BitmapShouldInitializeSharedState(), btparallelrescan(), CheckpointerMain(), CheckRecoveryConsistency(), CheckXLogRemoved(), ClockSweepTick(), ConditionVariableBroadcast(), ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), ConditionVariableSignal(), ConditionVariableTimedSleep(), copy_replication_slot(), CreateCheckPoint(), CreateInitDecodingContext(), CreateRestartPoint(), DecodingContextFindStartpoint(), do_pg_start_backup(), do_pg_stop_backup(), element_alloc(), FirstCallSinceLastCheckpoint(), get_hash_entry(), GetCurrentChunkReplayStartTime(), GetFakeLSNForUnloggedRel(), GetFlushRecPtr(), GetInsertRecPtr(), GetLatestXTime(), GetOldSnapshotThresholdTimestamp(), GetRecoveryState(), GetRedoRecPtr(), GetReplicationApplyDelay(), GetReplicationTransferLatency(), GetSnapshotCurrentTimestamp(), GetWalRcvFlushRecPtr(), GetXLogInsertRecPtr(), GetXLogReplayRecPtr(), GetXLogWriteRecPtr(), hash_search_with_hash_value(), HaveNFreeProcs(), HotStandbyActive(), InitAuxiliaryProcess(), InitProcess(), InitWalSenderSlot(), InvalidateObsoleteReplicationSlots(), KnownAssignedXidsAdd(), KnownAssignedXidsGetAndSetXmin(), KnownAssignedXidsGetOldestXmin(), KnownAssignedXidsSearch(), leader_takeover_tapes(), lock_twophase_recover(), LockRefindAndRelease(), LogicalConfirmReceivedLocation(), LogicalIncreaseRestartDecodingForSlot(), LogicalIncreaseXminForSlot(), LogicalRepSyncTableStart(), LWLockNewTrancheId(), MaintainOldSnapshotTimeMapping(), need_gc_qtexts(), ParallelWorkerReportLastRecEnd(), pg_atomic_clear_flag_impl(), 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_test_set_flag_impl(), pg_atomic_write_u32_impl(), pg_get_replication_slots(), pg_physical_replication_slot_advance(), 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(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyReplyMessage(), ProcessWalSndrMessage(), ProcKill(), ProcSendSignal(), PromoteIsTriggered(), PublishStartupProcessInformation(), qtext_store(), ReadRecord(), RecoveryIsPaused(), RecoveryRestartPoint(), RemoveLocalLock(), ReplicationSlotAcquireInternal(), ReplicationSlotCleanup(), ReplicationSlotCreate(), ReplicationSlotDropPtr(), ReplicationSlotMarkDirty(), ReplicationSlotPersist(), ReplicationSlotRelease(), ReplicationSlotReserveWal(), ReplicationSlotsComputeLogicalRestartLSN(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), ReplicationSlotsCountDBSlots(), ReplicationSlotsDropDBSlots(), RequestCheckpoint(), RequestXLogStreaming(), ReserveXLogInsertLocation(), ReserveXLogSwitch(), SaveSlotToPath(), SetCurrentChunkStartTime(), SetLatestXTime(), SetOldSnapshotThresholdTimestamp(), SetPromoteIsTriggered(), SetRecoveryPause(), SetWalWriterSleeping(), SharedFileSetAttach(), SharedFileSetOnDetach(), shm_mq_detach_internal(), shm_mq_get_receiver(), shm_mq_get_sender(), shm_mq_sendv(), shm_mq_set_receiver(), shm_mq_set_sender(), shm_mq_wait_internal(), shm_toc_allocate(), shm_toc_freespace(), shm_toc_insert(), ShmemAllocRaw(), ShutdownWalRcv(), SIGetDataEntries(), SIInsertDataEntries(), SnapshotTooOldMagicForTest(), StartLogicalReplication(), StartReplication(), StartupXLOG(), StrategyFreeBuffer(), StrategyGetBuffer(), StrategyNotifyBgWriter(), StrategySyncStart(), SyncRepGetCandidateStandbys(), SyncRepInitConfig(), table_block_parallelscan_startblock_init(), test_atomic_spin_nest(), test_shm_mq_main(), test_spinlock(), TransactionIdLimitedForOldSnapshots(), UpdateLastRemovedPtr(), UpdateMinRecoveryPoint(), wait_for_workers_to_become_ready(), WaitXLogInsertionsToFinish(), WalRcvDie(), WalRcvForceReply(), WalRcvRunning(), WalRcvStreaming(), WalRcvWaitForStartPosition(), WalReceiverMain(), WalSndInitStopping(), WalSndKill(), WalSndRqstFileReload(), WalSndSetState(), WalSndWaitStopping(), WalSndWakeup(), worker_freeze_result_tape(), worker_get_identifier(), xlog_redo(), XLogBackgroundFlush(), XLogFlush(), XLogGetLastRemovedSegno(), XLogGetReplicationSlotMinimumLSN(), XLogInsertRecord(), XLogNeedsFlush(), XLogSendLogical(), XLogSendPhysical(), XLogSetAsyncXactLSN(), XLogSetReplicationSlotMinimumLSN(), XLogWalRcvFlush(), and XLogWrite().

Function Documentation

◆ SpinlockSemaInit()

void SpinlockSemaInit ( void  )

Definition at line 77 of file spin.c.

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

Referenced by CreateSharedMemoryAndSemaphores().

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

◆ SpinlockSemas()

int SpinlockSemas ( void  )

Definition at line 64 of file spin.c.

References NUM_EMULATION_SEMAPHORES.

Referenced by CreateSharedMemoryAndSemaphores(), and SpinlockSemaInit().

65 {
67 }
#define NUM_EMULATION_SEMAPHORES
Definition: spin.c:37

◆ SpinlockSemaSize()

Size SpinlockSemaSize ( void  )

Definition at line 55 of file spin.c.

References NUM_EMULATION_SEMAPHORES.

Referenced by CreateSharedMemoryAndSemaphores(), and SpinlockSemaInit().

56 {
57  return NUM_EMULATION_SEMAPHORES * sizeof(PGSemaphore);
58 }
#define NUM_EMULATION_SEMAPHORES
Definition: spin.c:37
struct PGSemaphoreData * PGSemaphore
Definition: pg_sema.h:34

Variable Documentation

◆ SpinlockSemaArray

PGSemaphore* SpinlockSemaArray

Definition at line 42 of file spin.c.

Referenced by PostmasterMarkPIDForWorkerNotify().