]> rtime.felk.cvut.cz Git - frescor/fosa.git/blobdiff - src_marte/tests/test_non_local_jump/testbench_long_jump.c
Migrating FOSA trunk to d-ac2v2. Phase 1 moving FRSH-FOSA to FOSA
[frescor/fosa.git] / src_marte / tests / test_non_local_jump / testbench_long_jump.c
index 302ea8fa82884e1657126301823df13493e0e5e2..4fef93453dff972c0dbfa00120006050007ead68 100644 (file)
 #include <unistd.h>
 #include <time.h> // For clock_nanosleep
 
-#include "frsh_error.h"
 #include "fosa.h"
-#include "frsh_fosa.h"
 #include "timespec_operations.h"
 
+#include <misc/error_checks.h>
 
 
 /*************************/
@@ -66,10 +65,9 @@ struct timespec before_jump_timestamp = {-1, -1};
 
 int main()
 {
-    int terror = -1;
-    frsh_thread_attr_t periodic_attr;
-    frsh_signal_t signal_set[1];
-    frsh_thread_id_t periodic_tid;
+    fosa_thread_attr_t periodic_attr;
+    fosa_signal_t signal_set[1];
+    fosa_thread_id_t periodic_tid;
     results_t results;
 
     memset(&context, 0, sizeof(context) );
@@ -81,14 +79,14 @@ int main()
 
     /* We set the signal mask */
     signal_set[0] = FOSA_LONG_JUMP_SIGNAL;
-    PRW(  fosa_set_accepted_signals(signal_set, 1) );
+    CHK(  fosa_set_accepted_signals(signal_set, 1) );
 
     /* We create a new thread with a given priority */
-    PRW(  fosa_thread_set_prio(fosa_thread_self(), MAIN_THREAD_PRIORITY) );
+    CHK(  fosa_thread_set_prio(fosa_thread_self(), MAIN_THREAD_PRIORITY) );
 
-    PRW(  frsh_thread_attr_init(&periodic_attr) );
-    PRW(  fosa_thread_attr_set_prio(&periodic_attr, PERIODIC_THREAD_PRIORITY)  );
-    PRW(  fosa_thread_create(&periodic_tid, &periodic_attr, periodic_code, &results) );
+    CHK(  fosa_thread_attr_init(&periodic_attr) );
+    CHK(  fosa_thread_attr_set_prio(&periodic_attr, PERIODIC_THREAD_PRIORITY)  );
+    CHK(  fosa_thread_create(&periodic_tid, &periodic_attr, periodic_code, &results) );
 
     printf("Main waits for the periodic code to finish...\n");
     pthread_join(periodic_tid, NULL);
@@ -110,13 +108,10 @@ int main()
 
 static void *periodic_code(void *thread_arg)
 {
-    int terror = -1;
+    fosa_thread_id_t jump_handler_thread;
 
-    struct timespec period = {2, 500000000};  // 2.5 secs
-    frsh_thread_id_t jump_handler_thread;
-
-    frsh_signal_t jump_signal;
-    frsh_signal_info_t jump_signal_info;
+    fosa_signal_t jump_signal;
+    fosa_signal_info_t jump_signal_info;
 
     fosa_clock_id_t clock_id;
     fosa_timer_id_t jump_timer;
@@ -138,7 +133,7 @@ static void *periodic_code(void *thread_arg)
     /* - This creates the thread that will wait for */
     /*   FOSA_JUMP_SIGNAL                           */
     /************************************************/
-    PXW(  fosa_long_jump_install_handler(&jump_signal, &jump_handler_thread) );
+    CHK(  fosa_long_jump_install_handler(&jump_signal, &jump_handler_thread) );
     
     /* We create a budget timer using the thread's CPU clock */
     /*                                                       */
@@ -148,9 +143,9 @@ static void *periodic_code(void *thread_arg)
     /*                                                       */
     /* This signal is delivered to the handler thread.       */
     /*********************************************************/
-    PXW(  fosa_thread_get_cputime_clock( fosa_thread_self(), &clock_id) );
+    CHK(  fosa_thread_get_cputime_clock( fosa_thread_self(), &clock_id) );
     jump_signal_info.sival_ptr = &context;
-    PXW(  fosa_timer_create_with_receiver(clock_id, jump_signal, jump_signal_info, 
+    CHK(  fosa_timer_create_with_receiver(clock_id, jump_signal, jump_signal_info, 
                                           &jump_timer, jump_handler_thread)  );
 
     results->number_of_jumps = 0;