From f1d1234775f0bf6f1e8945e4677c7590d1db931e Mon Sep 17 00:00:00 2001 From: glenux Date: Tue, 24 Feb 2004 09:31:11 +0000 Subject: [PATCH] *** empty log message *** --- src/proto.h | 12 ++++++++---- src/queueProtLock.c | 4 ++-- src/queueProtUnlock.c | 4 ++-- src/queueReadLock.c | 26 ++++++++++++++++++++++++++ src/queueReadUnlock.c | 26 ++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 src/queueReadLock.c create mode 100644 src/queueReadUnlock.c diff --git a/src/proto.h b/src/proto.h index ccd471d..cbd5c9f 100644 --- a/src/proto.h +++ b/src/proto.h @@ -61,14 +61,18 @@ int msgQueueElemDelete(msgQueueElemId queueElemId); void *msgQueueElemOpen(msgQueueElemId queueElemId); /* queueInit.c */ msgQueue *queueInit(msgSpaceId externId, int queueIdx); -/* queueLock.c */ -int queueLock(msgSpaceId externId, int queueIdx); /* queueOpen.c */ void *msgQueueOpen(msgQueueId queueId); +/* queueProtLock.c */ +int queueProtLock(msgSpaceId externId, int queueIdx); +/* queueProtUnlock.c */ +int queueProtUnlock(msgSpaceId externId, int queueIdx); +/* queueReadLock.c */ +int queueReadLock(msgSpaceId externId, int queueIdx); +/* queueReadUnlock.c */ +int queueReadUnlock(msgSpaceId externId, int queueIdx); /* queueRem.c */ int msgQueueElemRem(msgQueue *queue, msgQueueElemId oldElemId); -/* queueUnlock.c */ -int queueUnlock(msgSpaceId externId, int queueIdx); /* spaceCreate.c */ msgSpace *msgSpaceCreate(msgSpaceId externId, int queueNb, int poolNb, msgPool *poolInfos); /* spaceDelete.c */ diff --git a/src/queueProtLock.c b/src/queueProtLock.c index 393909f..a80405c 100644 --- a/src/queueProtLock.c +++ b/src/queueProtLock.c @@ -1,11 +1,11 @@ #include "libnazgul.h" #include "ids.h" -int queueLock(msgSpaceId externId,int queueIdx){ +int queueProtLock(msgSpaceId externId,int queueIdx){ sem_t * queueSemFd; msgQueueSemId queueSemId; - msgQueueSemIdIntern(queueSemId,externId,queueIdx); + msgQueueProtSemIdIntern(queueSemId,externId,queueIdx); queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1); if(queueSemFd==SEM_FAILED){ NZG_ERROR("sem_open",queueSemId); diff --git a/src/queueProtUnlock.c b/src/queueProtUnlock.c index 0306195..bebe704 100644 --- a/src/queueProtUnlock.c +++ b/src/queueProtUnlock.c @@ -1,11 +1,11 @@ #include "libnazgul.h" #include "ids.h" -int queueUnlock(msgSpaceId externId,int queueIdx){ +int queueProtUnlock(msgSpaceId externId,int queueIdx){ sem_t * queueSemFd; msgQueueSemId queueSemId; - msgQueueSemIdIntern(queueSemId,externId,queueIdx); + msgQueueProtSemIdIntern(queueSemId,externId,queueIdx); queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1); if(queueSemFd==SEM_FAILED){ NZG_ERROR("sem_open",queueSemId); diff --git a/src/queueReadLock.c b/src/queueReadLock.c new file mode 100644 index 0000000..24a9ece --- /dev/null +++ b/src/queueReadLock.c @@ -0,0 +1,26 @@ +#include "libnazgul.h" +#include "ids.h" + +int queueReadLock(msgSpaceId externId,int queueIdx){ + sem_t * queueSemFd; + msgQueueSemId queueSemId; + + msgQueueReadSemIdIntern(queueSemId,externId,queueIdx); + queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1); + if(queueSemFd==SEM_FAILED){ + NZG_ERROR("sem_open",queueSemId); + goto ERROR; + } + + if(sem_wait(queueSemFd)==-1){ + NZG_ERROR("sem_wait",queueSemId); + goto ERROR; + } + + sem_close(queueSemFd); + + return 0; +ERROR: + return -1; +} + diff --git a/src/queueReadUnlock.c b/src/queueReadUnlock.c new file mode 100644 index 0000000..cb05b02 --- /dev/null +++ b/src/queueReadUnlock.c @@ -0,0 +1,26 @@ +#include "libnazgul.h" +#include "ids.h" + +int queueReadUnlock(msgSpaceId externId,int queueIdx){ + sem_t * queueSemFd; + msgQueueSemId queueSemId; + + msgQueueReadSemIdIntern(queueSemId,externId,queueIdx); + queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1); + if(queueSemFd==SEM_FAILED){ + NZG_ERROR("sem_open",queueSemId); + goto ERROR; + } + + if(sem_post(queueSemFd)==-1){ + NZG_ERROR("sem_post",queueSemId); + goto ERROR; + } + + sem_close(queueSemFd); + + return 0; +ERROR: + return -1; +} +