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