Commit 49535733 authored by Franksen, Benjamin's avatar Franksen, Benjamin
Browse files

vcan: fixed csem implementation (see BESSY Operations Trac #1456)

parent c154d07a
......@@ -379,8 +379,8 @@ typedef struct
typedef epicsEventId bosi_semaphore;
typedef struct
{
int taken;
int given;
unsigned int taken;
unsigned int given;
epicsMutexId mutex;
epicsEventId trigger;
} bosi_csemaphore;
......@@ -742,14 +742,13 @@ BSTATIC void bosi_sem_init(bosi_semaphore *sem)
BSTATIC void bosi_csem_wait(bosi_csemaphore *sem)
{
epicsMutexMustLock(sem->mutex);
while (sem->given<=sem->taken)
while (sem->given==sem->taken)
{
epicsMutexUnlock(sem->mutex);
epicsEventWait(sem->trigger);
epicsMutexMustLock(sem->mutex);
}
if (sem->given>++sem->taken)
epicsEventSignal(sem->trigger);
sem->taken++;
epicsMutexUnlock(sem->mutex);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment