summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2012-04-10 11:51:37 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-04-11 10:08:40 -0500
commit9a4e1b88e729bf939f0768bea0a1a990e6782dd9 (patch)
tree8b41365d30768fa48dc81e6ed47d7843bba6baab /src/usr
parent90bf338378eefa0af92585ff106add8df03dc163 (diff)
downloadtalos-hostboot-9a4e1b88e729bf939f0768bea0a1a990e6782dd9.tar.gz
talos-hostboot-9a4e1b88e729bf939f0768bea0a1a990e6782dd9.zip
Fix deadlock in synctest.H
A barrier was reinitialized by the testcase driver task prior to all the previous tasks leaving the barrier. This causes a permanent deadlock for the next set of tasks. Add a task_wait call to ensure all children have exited the barrier (and exited) prior to reusing the barrier. Change-Id: I537090da662d79796ada42befd1a12c7acdaa148 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/872 Tested-by: Jenkins Server Reviewed-by: Terry J. Opie <opiet@us.ibm.com> Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/testcore/lib/synctest.H67
1 files changed, 37 insertions, 30 deletions
diff --git a/src/usr/testcore/lib/synctest.H b/src/usr/testcore/lib/synctest.H
index a5d15b3f2..3f6f6e248 100644
--- a/src/usr/testcore/lib/synctest.H
+++ b/src/usr/testcore/lib/synctest.H
@@ -92,16 +92,19 @@ class SyncTest: public CxxTest::TestSuite
barrier_init(&barrier,4);
- TASK_INFO t1(this,1);
- TASK_INFO t2(this,2);
- TASK_INFO t3(this,3);
+ TASK_INFO t1 = { this, 1, 0};
+ TASK_INFO t2 = { this, 2, 0};
+ TASK_INFO t3 = { this, 3, 0};
- task_create(watch_counter, &t1);
- task_create(increment, &t2);
- task_create(increment, &t3);
+ t1.tid = task_create(watch_counter, &t1);
+ t2.tid = task_create(increment, &t2);
+ t3.tid = task_create(increment, &t3);
barrier_wait(&barrier);
TS_TRACE("Conditional Variable test final count = %ld",counter);
+ task_wait_tid(t1.tid, NULL, NULL);
+ task_wait_tid(t2.tid, NULL, NULL);
+ task_wait_tid(t3.tid, NULL, NULL);
barrier_destroy(&barrier);
sync_cond_destroy(&cond_var);
mutex_destroy(&mutex);
@@ -117,18 +120,22 @@ class SyncTest: public CxxTest::TestSuite
barrier_init(&barrier,5);
- TASK_INFO t1(this,4);
- TASK_INFO t2(this,5);
- TASK_INFO t3(this,6);
- TASK_INFO t4(this,7);
+ TASK_INFO t1 = { this, 4, 0};
+ TASK_INFO t2 = { this, 5, 0};
+ TASK_INFO t3 = { this, 6, 0};
+ TASK_INFO t4 = { this, 7, 0};
- task_create(watch_counter, &t1);
- task_create(watch_counter, &t2);
- task_create(increment1, &t3);
- task_create(increment1, &t4);
+ t1.tid = task_create(watch_counter, &t1);
+ t2.tid = task_create(watch_counter, &t2);
+ t3.tid = task_create(increment1, &t3);
+ t4.tid = task_create(increment1, &t4);
barrier_wait(&barrier);
TS_TRACE("Conditional Variable test final count = %ld",counter);
+ task_wait_tid(t1.tid, NULL, NULL);
+ task_wait_tid(t2.tid, NULL, NULL);
+ task_wait_tid(t3.tid, NULL, NULL);
+ task_wait_tid(t4.tid, NULL, NULL);
barrier_destroy(&barrier);
sync_cond_destroy(&cond_var);
mutex_destroy(&mutex);
@@ -137,17 +144,17 @@ class SyncTest: public CxxTest::TestSuite
-
+
private:
- enum
- {
+ enum
+ {
TO_COUNT = 10,
COUNT_SIGNAL = 13
};
- typedef std::pair<SyncTest*, size_t> TASK_INFO;
+ struct TASK_INFO { SyncTest* testobj; size_t id; tid_t tid; };
mutex_t mutex;
barrier_t barrier;
@@ -201,17 +208,17 @@ class SyncTest: public CxxTest::TestSuite
static void watch_counter(void * i_p)
{
TASK_INFO * info = (TASK_INFO *) i_p;
- SyncTest * my = info->first;
- TS_TRACE("CONDVAR task %ld. Start watching counter",info->second);
+ SyncTest * my = info->testobj;
+ TS_TRACE("CONDVAR task %ld. Start watching counter",info->id);
mutex_lock(&(my->mutex));
while(my->counter < COUNT_SIGNAL)
{
sync_cond_wait(&(my->cond_var),&(my->mutex));
TS_TRACE("CONDVAR task %ld. Condition signal received",
- info->second);
+ info->id);
my->counter += 100;
TS_TRACE("CONDVAR task %ld. Counter = %ld",
- info->second,my->counter);
+ info->id,my->counter);
}
mutex_unlock(&(my->mutex));
barrier_wait(&(my->barrier));
@@ -221,8 +228,8 @@ class SyncTest: public CxxTest::TestSuite
static void increment(void * i_p)
{
TASK_INFO * info = (TASK_INFO *) i_p;
- SyncTest * my = info->first;
- TS_TRACE("CONDVAR task %ld. start Increment counter",info->second);
+ SyncTest * my = info->testobj;
+ TS_TRACE("CONDVAR task %ld. start Increment counter",info->id);
for(size_t i = 0; i < TO_COUNT; ++i)
{
mutex_lock(&(my->mutex));
@@ -232,10 +239,10 @@ class SyncTest: public CxxTest::TestSuite
{
sync_cond_signal(&(my->cond_var));
TS_TRACE("CONDVAR task %ld. INCR counter = %ld Threshold"
- " reached",info->second,my->counter);
+ " reached",info->id,my->counter);
}
TS_TRACE("CONDVAR task %ld INCR counter = %ld Unlocking mutex",
- info->second, my->counter);
+ info->id, my->counter);
mutex_unlock(&(my->mutex));
nanosleep(0,TEN_CTX_SWITCHES_NS);
}
@@ -245,8 +252,8 @@ class SyncTest: public CxxTest::TestSuite
static void increment1(void * i_p)
{
TASK_INFO * info = (TASK_INFO *) i_p;
- SyncTest * my = info->first;
- TS_TRACE("CONDVAR task %ld. start Increment counter",info->second);
+ SyncTest * my = info->testobj;
+ TS_TRACE("CONDVAR task %ld. start Increment counter",info->id);
for(size_t i = 0; i < TO_COUNT; ++i)
{
mutex_lock(&(my->mutex));
@@ -256,10 +263,10 @@ class SyncTest: public CxxTest::TestSuite
{
sync_cond_broadcast(&(my->cond_var));
TS_TRACE("CONDVAR task %ld. INCR counter = %ld Threshold"
- " reached",info->second,my->counter);
+ " reached",info->id,my->counter);
}
TS_TRACE("CONDVAR task %ld INCR counter = %ld Unlocking mutex",
- info->second, my->counter);
+ info->id, my->counter);
mutex_unlock(&(my->mutex));
nanosleep(0,TEN_CTX_SWITCHES_NS);
}
OpenPOWER on IntegriCloud