#include "postgres.h"#include "miscadmin.h"#include "replication/walsender.h"#include "storage/lwlock.h"#include "storage/spin.h"
Go to the source code of this file.
Functions | |
| int | SpinlockSemas (void) |
| void | s_init_lock_sema (volatile slock_t *lock) |
| void | s_unlock_sema (volatile slock_t *lock) |
| bool | s_lock_free_sema (volatile slock_t *lock) |
| int | tas_sema (volatile slock_t *lock) |
| void s_init_lock_sema | ( | volatile slock_t * | lock | ) |
Definition at line 76 of file spin.c.
References PGSemaphoreCreate().
{
PGSemaphoreCreate((PGSemaphore) lock);
}
| void s_unlock_sema | ( | volatile slock_t * | lock | ) |
Definition at line 82 of file spin.c.
References PGSemaphoreUnlock().
{
PGSemaphoreUnlock((PGSemaphore) lock);
}
| int SpinlockSemas | ( | void | ) |
Definition at line 52 of file spin.c.
References max_wal_senders, NBuffers, and NumLWLocks().
Referenced by CreateSharedMemoryAndSemaphores().
{
int nsemas;
/*
* It would be cleaner to distribute this logic into the affected modules,
* similar to the way shmem space estimation is handled.
*
* For now, though, there are few enough users of spinlocks that we just
* keep the knowledge here.
*/
nsemas = NumLWLocks(); /* one for each lwlock */
nsemas += NBuffers; /* one for each buffer header */
nsemas += max_wal_senders; /* one for each wal sender process */
nsemas += 30; /* plus a bunch for other small-scale use */
return nsemas;
}
| int tas_sema | ( | volatile slock_t * | lock | ) |
Definition at line 96 of file spin.c.
References PGSemaphoreTryLock().
{
/* Note that TAS macros return 0 if *success* */
return !PGSemaphoreTryLock((PGSemaphore) lock);
}
1.7.1