From: Gilles Carry <[EMAIL PROTECTED]>
This flag is set by timer_thread when the sampling is finished.
This fixes this deadlock/race condition:
1. busy threads run until main thread exits
2. main thread waits for timer_thread to finish
3. timer_thread is writing samples results into
files and waits for a filesystem global lock to be released
4. sync threads (kjournald, pdflush) with non-rt prio hold
the above mentioned lock and cannot finish their job because
cpu is hogged by busy threads.
Solution: tell busy threads to quit before writing to disk.
Signed-off-by: Gilles Carry <[EMAIL PROTECTED]>
Cc: Darren Hart <[EMAIL PROTECTED]>
Cc: Tim Chavez <[EMAIL PROTECTED]>
---
.../realtime/func/hrtimer-prio/hrtimer-prio.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
b/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
index f22ca83..9e051aa 100644
--- a/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
+++ b/testcases/realtime/func/hrtimer-prio/hrtimer-prio.c
@@ -63,6 +63,7 @@ static int busy_time = DEF_BUSY_TIME;
static int iterations = DEF_ITERATIONS;
static unsigned long criteria = DEF_CRITERIA;
static int busy_threads;
+static int busy_exit = 0;
static stats_container_t dat;
static atomic_t busy_threads_started;
@@ -117,7 +118,7 @@ int parse_args(int c, char *v)
void *busy_thread(void *thread)
{
atomic_inc(&busy_threads_started);
- while (1) {
+ while (!busy_exit) {
busy_work_ms(busy_time);
sched_yield();
}
@@ -146,6 +147,7 @@ void *timer_thread(void *thread)
max_delta = MAX(max_delta, delta_us);
min_delta = (i == 0) ? delta_us : MIN(min_delta, delta_us);
}
+ busy_exit = 1; // Tell busy_threads to exit.
return NULL;
}
--
1.5.4.3.450.gb92176
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list