Commit 1e037861 authored by claes's avatar claes

Changed qcom interprocess sync-mechanism from futex to interprocess mutex/condvar

parent 61c6885a
/*
* Proview $Id: rt_qos.c,v 1.8 2005-09-01 14:57:57 claes Exp $
* Proview $Id: rt_qos.c,v 1.9 2007-09-21 09:05:41 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -113,6 +113,7 @@ qos_WaitQue (
)
{
pwr_tDeltaTime dtime;
pwr_tTime atime;
int ok;
pwr_tBoolean signal = FALSE;
pwr_dStatus (sts, status, QCOM__SUCCESS);
......@@ -122,27 +123,23 @@ qos_WaitQue (
if (tmo == qcom_cTmoNone)
return FALSE;
pthread_mutex_lock(&qp->lock.mutex);
qp->lock.waiting = TRUE;
qp->lock.pid = 0;
qdb_Unlock;
if (qp->lock.waiting) {
if (tmo != qcom_cTmoEternal) {
ok = futex_timed_wait(&(qp->lock.pid), 0, (struct timespec *) time_MsToD(&dtime, tmo));
} else {
for (;;) {
ok = futex_wait(&(qp->lock.pid), 0);
if (ok == EINTR)
continue;
break;
}
}
if (ok == EWOULDBLOCK) {
errh_Error("waitQue - Deadlock would occur");
}
if (tmo != qcom_cTmoEternal) {
clock_gettime(CLOCK_REALTIME, &atime);
time_MsToD(&dtime, tmo);
time_Aadd(&atime, &atime, &dtime);
ok = pthread_cond_timedwait(&qp->lock.cond, &qp->lock.mutex, (struct timespec *) &atime);
} else {
ok = pthread_cond_wait(&qp->lock.cond, &qp->lock.mutex);
}
pthread_mutex_unlock(&qp->lock.mutex);
qdb_Lock;
......@@ -189,17 +186,17 @@ qos_SignalQue (
qdb_sQue *qp
)
{
int ok;
pwr_dStatus (sts, status, QCOM__SUCCESS);
qdb_AssumeLocked;
// if (qp->lock.waiting) {
qp->lock.waiting = FALSE;
pthread_mutex_lock(&qp->lock.mutex);
ok = futex_wake(&(qp->lock.pid), INT_MAX);
qp->lock.waiting = FALSE;
// }
pthread_cond_signal(&qp->lock.cond);
pthread_mutex_unlock(&qp->lock.mutex);
return TRUE;
}
......
/*
* Proview $Id: rt_qdb.c,v 1.10 2006-02-14 05:27:43 claes Exp $
* Proview $Id: rt_qdb.c,v 1.11 2007-09-21 09:05:41 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -1220,6 +1220,8 @@ qdb_AddQue (
{
qdb_sQue *qp;
pwr_dStatus (sts, status, QCOM__SUCCESS);
pthread_condattr_t condattr;
pthread_mutexattr_t mutexattr;
qdb_AssumeLocked;
......@@ -1246,6 +1248,14 @@ qdb_AddQue (
pool_Qinit(NULL, &qdb->pool, &qp->rep_lh);
pool_Qinit(NULL, &qdb->pool, &qp->read_lh);
qp->qix = qix;
pthread_condattr_init(&condattr);
pthread_condattr_setpshared(&condattr, PTHREAD_PROCESS_SHARED);
pthread_mutexattr_init(&mutexattr);
pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED);
pthread_mutex_init(&qp->lock.mutex, &mutexattr);
pthread_cond_init(&qp->lock.cond, &condattr);
qp = hash_Insert(sts, &qdb->qix_ht, qp);
return qp;
......
/*
* Proview $Id: rt_qdb.h,v 1.9 2006-03-20 07:17:01 claes Exp $
* Proview $Id: rt_qdb.h,v 1.10 2007-09-21 09:05:41 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -474,6 +474,8 @@ typedef struct {
typedef struct {
int pid;
int waiting;
pthread_mutex_t mutex;
pthread_cond_t cond;
} qdb_sQlock;
#endif
......
Markdown is supported
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