mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
replaced pthread_mutex_t with sem_t
This commit is contained in:
parent
e91420bd16
commit
539c0c295b
@ -2,7 +2,7 @@
|
||||
#include "clogger.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <string.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
@ -19,9 +19,9 @@
|
||||
|
||||
typedef struct Memory {
|
||||
int version;
|
||||
pthread_mutex_t lockStatus;
|
||||
sem_t semStatus;
|
||||
#ifdef EIGERD
|
||||
pthread_mutex_t lockLocalLink;
|
||||
sem_t semLocalLink;
|
||||
#endif
|
||||
enum runStatus scanStatus; // idle, running or error
|
||||
int scanStop;
|
||||
@ -87,14 +87,14 @@ int sharedMemory_create(int port) {
|
||||
|
||||
int sharedMemory_initialize() {
|
||||
shm->version = SHM_VERSION;
|
||||
if (pthread_mutex_init(&(shm->lockStatus), NULL) != 0) {
|
||||
LOG(logERROR, ("Failed to initialize pthread_mutex_t lockStatus for "
|
||||
if (sem_init(&(shm->semStatus), 1, 1) != 0) {
|
||||
LOG(logERROR, ("Failed to initialize semaphore semStatus for "
|
||||
"shared memory\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef EIGERD
|
||||
if (pthread_mutex_init(&(shm->lockLocalLink), NULL) != 0) {
|
||||
LOG(logERROR, ("Failed to initialize pthread_mutex_t lockLocalLink for "
|
||||
if (sem_init(&(shm->semLocalLink), 1, 1) != 0) {
|
||||
LOG(logERROR, ("Failed to initialize semaphore semLocalLink for "
|
||||
"shared memory\n"));
|
||||
return FAIL;
|
||||
}
|
||||
@ -155,9 +155,9 @@ int sharedMemory_remove() {
|
||||
return OK;
|
||||
}
|
||||
|
||||
void sharedMemory_lockStatus() { pthread_mutex_lock(&(shm->lockStatus)); }
|
||||
void sharedMemory_lockStatus() { sem_wait(&(shm->semStatus)); }
|
||||
|
||||
void sharedMemory_unlockStatus() { pthread_mutex_unlock(&(shm->lockStatus)); }
|
||||
void sharedMemory_unlockStatus() { sem_post(&(shm->semStatus)); }
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void sharedMemory_setStatus(enum runStatus s) {
|
||||
@ -218,9 +218,7 @@ int sharedMemory_getScanStop() {
|
||||
}
|
||||
|
||||
#ifdef EIGERD
|
||||
void sharedMemory_lockLocalLink() { pthread_mutex_lock(&(shm->lockLocalLink)); }
|
||||
void sharedMemory_lockLocalLink() { sem_wait(&(shm->semLocalLink)); }
|
||||
|
||||
void sharedMemory_unlockLocalLink() {
|
||||
pthread_mutex_unlock(&(shm->lockLocalLink));
|
||||
}
|
||||
void sharedMemory_unlockLocalLink() { sem_post(&(shm->semLocalLink)); }
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user