]> rtime.felk.cvut.cz Git - frescor/fosa.git/blobdiff - src_marte/tests/test_non_local_jump/testbench_long_jump.c
Time abstraction added to FOSA to replace timespec_operations
[frescor/fosa.git] / src_marte / tests / test_non_local_jump / testbench_long_jump.c
index 4fef93453dff972c0dbfa00120006050007ead68..ddae7ab83522782de375e7de5d47bfbe6c25e6ba 100644 (file)
@@ -24,7 +24,6 @@
 #include <time.h> // For clock_nanosleep
 
 #include "fosa.h"
-#include "timespec_operations.h"
 
 #include <misc/error_checks.h>
 
@@ -60,7 +59,7 @@ static void *periodic_code(void *thread_arg);
 static fosa_long_jump_context_t context;
 static void work_under_a_interruptible_budget();
 
-struct timespec before_jump_timestamp = {-1, -1};
+fosa_abs_time_t before_jump_timestamp;
 
 
 int main()
@@ -72,10 +71,6 @@ int main()
 
     memset(&context, 0, sizeof(context) );
 
-    memset(&periodic_attr, 0, sizeof(periodic_attr) );
-    memset(&signal_set, 0, sizeof(signal_set) );
-    memset(&periodic_tid, 0, sizeof(periodic_tid) );
-    memset(&results, 0, sizeof(results) );
 
     /* We set the signal mask */
     signal_set[0] = FOSA_LONG_JUMP_SIGNAL;
@@ -121,12 +116,6 @@ static void *periodic_code(void *thread_arg)
     int first_time = 1;
 
 
-    memset(&jump_signal, 0, sizeof(jump_signal) );
-    memset(&jump_signal_info, 0, sizeof(jump_signal_info) );
-    memset(&jump_handler_thread, 0, sizeof(jump_handler_thread) );
-    memset(&clock_id, 0, sizeof(clock_id) );
-    memset(&jump_timer, 0, sizeof(jump_timer) );
-
     results = (results_t *) thread_arg;
     
     /* We install a long jump handler               */
@@ -155,9 +144,10 @@ static void *periodic_code(void *thread_arg)
     while (results->number_of_jumps < NUMBER_OF_JUMPS)
     {
         int jumped = -1;
-        struct timespec budget = {0, 20000000};  // 20 ms
+        fosa_rel_time_t budget = fosa_msec_to_rel_time(20);  // 20 ms
 
-        struct timespec after_jump_timestamp = {-1, -1 };
+        fosa_abs_time_t after_jump_timestamp;
+        fosa_rel_time_t jump_interval;
         double jump_interval_ms = 0.0;
 
         
@@ -171,7 +161,7 @@ static void *periodic_code(void *thread_arg)
         /************************************/
 
         /* We arm the jump_timer */
-        fosa_timer_arm(jump_timer, false, &budget);
+        fosa_rel_timer_arm(jump_timer, &budget);
 
         
         /* This is the point where the jump returns */
@@ -191,8 +181,8 @@ static void *periodic_code(void *thread_arg)
             fosa_clock_get_time(FOSA_CLOCK_REALTIME, &after_jump_timestamp);
 
             results->number_of_jumps++;
-            decr_timespec(&after_jump_timestamp, &before_jump_timestamp);
-            jump_interval_ms = t2d(after_jump_timestamp) * 1000;
+            jump_interval = fosa_abs_time_extract_interval(before_jump_timestamp, after_jump_timestamp);
+            jump_interval_ms = fosa_rel_time_to_msec(jump_interval);
 
             if (first_time)
             {