#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>
/*************************/
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) );
/* 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);
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;
/* - 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 */
/* */
/* */
/* 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;