The 'period missed' check of the thread first loop should not depend on the
thread starting time. This is especially visible on 'slow' platforms where
one cannot run the test if thread creation takes a long time.

 Fix it by removing this dependency. All delays are now calculated relative
to when the thread starts.

Signed-off-by: Sebastien Dugue <[EMAIL PROTECTED]>
Cc: Darren Hart <[EMAIL PROTECTED]>
Cc: Tim Chavez <[EMAIL PROTECTED]>
Cc: Matthieu CASTET <[EMAIL PROTECTED]>
---
 .../realtime/func/sched_latency/sched_latency.c    |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/testcases/realtime/func/sched_latency/sched_latency.c 
b/testcases/realtime/func/sched_latency/sched_latency.c
index b7ba74b..8500525 100644
--- a/testcases/realtime/func/sched_latency/sched_latency.c
+++ b/testcases/realtime/func/sched_latency/sched_latency.c
@@ -121,12 +121,11 @@ void *periodic_thread(void *arg)
        int i;
        nsec_t delay, avg_delay = 0, start_delay, min_delay = -1ULL, max_delay 
= 0;
        int failures = 0;
-       nsec_t next = 0, now = 0, sched_delta = 0, delta = 0, prev = 0;
+       nsec_t next = 0, now = 0, sched_delta = 0, delta = 0, prev = 0, 
iter_start;
 
-       prev = start;
-       next = start;
        now = rt_gettime();
        start_delay = (now - start)/NS_PER_US;
+       iter_start = next = now;
 
        debug(DBG_INFO, "ITERATION DELAY(US) MAX_DELAY(US) FAILURES\n");
        debug(DBG_INFO, "--------- --------- ------------- --------\n");
@@ -147,9 +146,9 @@ void *periodic_thread(void *arg)
                        printf("        actual delta: %8llu us\n", delta/1000);
                        printf("             latency: %8llu us\n", 
(delta-sched_delta)/1000);
                        printf("---------------------------------------\n");
-                       printf("      previous start: %8llu us\n", 
(prev-start)/1000);
-                       printf("                 now: %8llu us\n", 
(now-start)/1000);
-                       printf("     scheduled start: %8llu us\n", 
(next-start)/1000);
+                       printf("      previous start: %8llu us\n", 
(prev-iter_start)/1000);
+                       printf("                 now: %8llu us\n", 
(now-iter_start)/1000);
+                       printf("     scheduled start: %8llu us\n", 
(next-iter_start)/1000);
                        printf("next scheduled start is in the past!\n");
                        ret = 1;
                        break;
@@ -167,7 +166,7 @@ void *periodic_thread(void *arg)
                } while (now < next);
 
                /* start of period */
-               delay = (now - start - (nsec_t)(i+1)*period)/NS_PER_US;
+               delay = (now - iter_start - (nsec_t)(i+1)*period)/NS_PER_US;
                dat.records[i].x = i;
                dat.records[i].y = delay;
                if (delay < min_delay)
-- 
1.5.4.rc2.84.gf85fd-dirty


-------------------------------------------------------------------------
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

Reply via email to