From 511c814ffbaea3d48414d14d4066d791d1e7d1b9 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 26 Oct 2014 16:38:00 +0800 Subject: [PATCH] refs #182: rename to sync test. --- trunk/research/st/srs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/trunk/research/st/srs.c b/trunk/research/st/srs.c index 5e25888b1..0de7942da 100644 --- a/trunk/research/st/srs.c +++ b/trunk/research/st/srs.c @@ -8,6 +8,7 @@ st_mutex_t sync_start = NULL; st_cond_t sync_cond = NULL; st_mutex_t sync_mutex = NULL; +st_cond_t sync_end = NULL; void* sync_master(void* arg) { @@ -50,11 +51,15 @@ void* sync_slave(void* arg) st_cond_wait(sync_cond); srs_trace("4. st is ok"); + st_cond_signal(sync_end); + return NULL; } int sync_test() { + srs_trace("sync test: start"); + if ((sync_start = st_mutex_new()) == NULL) { srs_trace("st_mutex_new sync_start failed"); return -1; @@ -65,6 +70,11 @@ int sync_test() srs_trace("st_cond_new cond failed"); return -1; } + + if ((sync_end = st_cond_new()) == NULL) { + srs_trace("st_cond_new end failed"); + return -1; + } if ((sync_mutex = st_mutex_new()) == NULL) { srs_trace("st_mutex_new mutex failed"); @@ -84,6 +94,9 @@ int sync_test() // run all threads. st_mutex_unlock(sync_start); + st_cond_wait(sync_end); + srs_trace("sync test: end"); + return 0; }