8#include <framework/pcore/SemaphoreLocker.h>
9#include <framework/logging/Logger.h>
21 int semid = semget(semkey, 1, IPC_CREAT | IPC_EXCL | 0600);
25 if (semctl(semid, 0, SETVAL, semval) == -1) {
26 B2ERROR(
"Initializing semaphore with semctl() failed.");
28 }
else if (errno == EEXIST) {
29 semid = semget(semkey, 1, 0600);
32 B2ERROR(
"Couldn't create semaphore with semget()! Maybe you have too many semaphores from aborted processes lying around, you can clean those up by running 'clear_basf2_ipc'.");
41 if (semctl(semId, 1, IPC_RMID) == -1) {
42 B2ERROR(
"Error in SemaphoreLocker::destroy(), semaphore " << semId <<
", error: " << strerror(errno));
49 int val = semctl(semId, 0, GETVAL, ignored);
55 void doSemOp(
int semID,
int op)
61 while (semop(semID, &sb, 1) == -1) {
66 B2FATAL(
"Another process was aborted, please check previous output for reasons. (" <<
67 strerror(errno) <<
" for semaphore " << semID <<
")");
static void destroy(int semId)
Destroy the given semaphore.
static int create(key_t semkey)
Create a new semaphore and initialize it.
void unlock()
Unlock the semaphore.
void lock()
Lock the semaphore.
int m_id
semaphore id, see semget(2).
static bool isLocked(int semId)
Return true if the given semaphore is locked.
Abstract base class for different kinds of events.