diff options
author | Jianxun Zhang <jianxun.zhang@linux.intel.com> | 2017-04-28 14:02:09 -0700 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2017-05-04 14:31:27 +0200 |
commit | 470b7394e60f0209e2a08e79617cfead0ef25ed2 (patch) | |
tree | 9bb3af669f8ada49e282ec1ed22f5a2a815d8dcd | |
parent | 193ed3d12ebe20817ac19a53a8f87c992283dda1 (diff) | |
download | rt-tests-470b7394e60f0209e2a08e79617cfead0ef25ed2.tar.gz |
cyclictest: cannot stop running with '-M' option
Most of time having '-M' option causes cyclictest won't exit after
a duration ('-D') expires, like this quick command on my machines:
sudo cyclictest -S -M -D2 -d0
This is because the main thread is blocked on waiting for the next
update of MAX, but the timer thread doesn't signal the main thread
before it quits.
Signed-off-by: Jianxun Zhang <jianxun.zhang@linux.intel.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r-- | src/cyclictest/cyclictest.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 48791c1..fceb152 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1241,6 +1241,17 @@ static void *timerthread(void *param) } out: + if (refresh_on_max) { + pthread_mutex_lock(&refresh_on_max_lock); + /* We could reach here with both shutdown and allstopped unset (0). + * Set shutdown with synchronization to notify the main + * thread not to be blocked when it should exit. + */ + shutdown++; + pthread_cond_signal(&refresh_on_max_cond); + pthread_mutex_unlock(&refresh_on_max_lock); + } + if (par->mode == MODE_CYCLIC) timer_delete(timer); @@ -2516,8 +2527,9 @@ int main(int argc, char **argv) if (refresh_on_max) { pthread_mutex_lock(&refresh_on_max_lock); - pthread_cond_wait(&refresh_on_max_cond, - &refresh_on_max_lock); + if (!shutdown) + pthread_cond_wait(&refresh_on_max_cond, + &refresh_on_max_lock); pthread_mutex_unlock(&refresh_on_max_lock); } } @@ -2527,6 +2539,9 @@ int main(int argc, char **argv) shutdown = 1; usleep(50000); + if (!verbose && !quiet && refresh_on_max) + printf("\033[%dB", num_threads + 2); + if (quiet) quiet = 2; for (i = 0; i < num_threads; i++) { |