#include <time.h> // For clock_nanosleep
#include "fosa.h"
-#include "timespec_operations.h"
#include <misc/error_checks.h>
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()
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;
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 */
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;
/************************************/
/* 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 */
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)
{