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.

◆ SpinLockFree

#define SpinLockFree (   lock)    S_LOCK_FREE(lock)

Definition at line 66 of file spin.h.

◆ SpinLockInit

#define SpinLockInit (   lock)    S_INIT_LOCK(lock)

Definition at line 60 of file spin.h.

◆ SpinLockRelease

#define SpinLockRelease (   lock)    S_UNLOCK(lock)

Definition at line 64 of file spin.h.

Function Documentation

◆ SpinlockSemaInit()

void SpinlockSemaInit ( void  )

Definition at line 77 of file spin.c.

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 }
int i
Definition: isn.c:73
PGSemaphore PGSemaphoreCreate(void)
Definition: posix_sema.c:262
void * ShmemAllocUnlocked(Size size)
Definition: shmem.c:247
Size SpinlockSemaSize(void)
Definition: spin.c:55
PGSemaphore * SpinlockSemaArray
Definition: spin.c:42
int SpinlockSemas(void)
Definition: spin.c:64

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

Referenced by CreateSharedMemoryAndSemaphores().

◆ SpinlockSemas()

int SpinlockSemas ( void  )

Definition at line 64 of file spin.c.

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

References NUM_EMULATION_SEMAPHORES.

Referenced by CalculateShmemSize(), and SpinlockSemaInit().

◆ SpinlockSemaSize()

Size SpinlockSemaSize ( void  )

Definition at line 55 of file spin.c.

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

References NUM_EMULATION_SEMAPHORES.

Referenced by CalculateShmemSize(), and SpinlockSemaInit().

Variable Documentation

◆ SpinlockSemaArray

PGSemaphore* SpinlockSemaArray
extern

Definition at line 42 of file spin.c.

Referenced by s_unlock_sema(), SpinlockSemaInit(), and tas_sema().