From: Jianxun Zhang <jianxun.zhang@linux.intel.com>
To: linux-rt-users@vger.kernel.org
Cc: Jianxun Zhang <jianxun.zhang@linux.intel.com>
Subject: [PATCH] cyclictest: cannot stop running with '-M' option
Date: Fri, 28 Apr 2017 14:02:09 -0700 [thread overview]
Message-ID: <1493413329-115349-1-git-send-email-jianxun.zhang@linux.intel.com> (raw)
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>
---
The issue may not happen every time, depending on your machine or other parameters fed to cyclictest, but it does quite often on my setup.
src/cyclictest/cyclictest.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 3f1bef1..36259ea 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);
@@ -2512,8 +2523,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);
}
}
@@ -2523,6 +2535,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++) {
--
2.7.4
next reply other threads:[~2017-04-28 20:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-28 21:02 Jianxun Zhang [this message]
2017-05-04 12:43 ` [PATCH] cyclictest: cannot stop running with '-M' option John Kacur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1493413329-115349-1-git-send-email-jianxun.zhang@linux.intel.com \
--to=jianxun.zhang@linux.intel.com \
--cc=linux-rt-users@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox