git-svn-id: http://www.frescor.org/private/svn/frescor/fosa/trunk@916
35b4ef3e-fd22-0410-ab77-
dab3279adceb
/*************************/
/* D E F I N I T I O N S */
/*************************/
/*************************/
/* D E F I N I T I O N S */
/*************************/
-#define NUMBER_OF_TESTS 100
+#define NUMBER_OF_TESTS 1000
static struct timespec minimum_budget_for_timer = {0, 100000}; // 100 us
static struct timespec minimum_budget_for_timer = {0, 100000}; // 100 us
#define CALIBRATE_THREAD_PRIORITY (fosa_get_priority_min() + 4)
#define MAIN_THREAD_PRIORITY (fosa_get_priority_min() + 3)
#define CALIBRATE_THREAD_PRIORITY (fosa_get_priority_min() + 4)
#define MAIN_THREAD_PRIORITY (fosa_get_priority_min() + 3)
+#define MUTEX_CEILING (fosa_get_priority_min() + 10)
#define MINIMUM_BUDGET_FOR_TIMER_USECS 100
#define SIGNAL_CALIBRATE_FINISHED (FRSH_SIGNAL_MIN + 6)
#define MINIMUM_BUDGET_FOR_TIMER_USECS 100
#define SIGNAL_CALIBRATE_FINISHED (FRSH_SIGNAL_MIN + 6)
typedef struct _individual_results_t
{
int first_time_passed;
typedef struct _individual_results_t
{
int first_time_passed;
individual_results_t *fixed_memory_copy_ovhd,
individual_results_t *memory_copy_per_byte_ovhd);
individual_results_t *fixed_memory_copy_ovhd,
individual_results_t *memory_copy_per_byte_ovhd);
-
-static void *calibrate_thread_code(void *thread_arg);
+static void *fixed_abort_ovhd_thread_code(void *thread_arg);
static void process_result(individual_results_t *results, struct timespec interval);
static void print_results(individual_results_t results);
static struct timespec timespec_divide_by_int(struct timespec numerator, long int denominator);
static void process_result(individual_results_t *results, struct timespec interval);
static void print_results(individual_results_t results);
static struct timespec timespec_divide_by_int(struct timespec numerator, long int denominator);
PRW( fosa_set_accepted_signals(signal_set, 1) );
PRW( fosa_thread_set_prio(fosa_thread_self(), MAIN_THREAD_PRIORITY) );
PRW( fosa_set_accepted_signals(signal_set, 1) );
PRW( fosa_thread_set_prio(fosa_thread_self(), MAIN_THREAD_PRIORITY) );
+ /* We get our CPU clock */
+ PRW( fosa_thread_get_cputime_clock( fosa_thread_self(), &cpu_clock) );
+
/* We measure the fixed_abort_ovhd */
/***********************************/
thread_data.results = fixed_abort_ovhd;
/* We measure the fixed_abort_ovhd */
/***********************************/
thread_data.results = fixed_abort_ovhd;
PRW( frsh_thread_attr_init(&calibrate_thread_attr) );
PRW( fosa_thread_attr_set_prio(&calibrate_thread_attr, CALIBRATE_THREAD_PRIORITY) );
PRW( frsh_thread_attr_init(&calibrate_thread_attr) );
PRW( fosa_thread_attr_set_prio(&calibrate_thread_attr, CALIBRATE_THREAD_PRIORITY) );
- PRW( fosa_thread_create(&calibrate_tid, &calibrate_thread_attr, calibrate_thread_code,
+
+ PRW( fosa_thread_create(&calibrate_tid, &calibrate_thread_attr, fixed_abort_ovhd_thread_code,
- printf("Main waits for the calibrate code to finish...\n");
+ /* We wait for the signal to arrive */
PRW( fosa_signal_wait(signal_set, 1, &signal_received, &signal_info_received) );
/* We measure fixed_memory_copy_ovhd */
/*************************************/
PRW( fosa_signal_wait(signal_set, 1, &signal_received, &signal_info_received) );
/* We measure fixed_memory_copy_ovhd */
/*************************************/
- PRW( fosa_thread_get_cputime_clock( fosa_thread_self(), &cpu_clock) );
-
-
for(i = 0 ; i < NUMBER_OF_TESTS ; i++)
{
for(i = 0 ; i < NUMBER_OF_TESTS ; i++)
{
- fosa_clock_get_time(FOSA_CLOCK_REALTIME, &initial_time);
+ fosa_clock_get_time(FOSA_CLOCK_REALTIME, &initial_time); // Start measurement
memcpy(memory_region_destination, memory_region_source, 0);
memcpy(memory_region_destination, memory_region_source, 0);
- fosa_clock_get_time(FOSA_CLOCK_REALTIME, &final_time);
+ fosa_clock_get_time(FOSA_CLOCK_REALTIME, &final_time); // End measurement
decr_timespec(&final_time, &initial_time);
decr_timespec(&final_time, &initial_time);
fosa_clock_get_time(cpu_clock, &final_time); // End measurement
decr_timespec(&final_time, &initial_time);
fosa_clock_get_time(cpu_clock, &final_time); // End measurement
decr_timespec(&final_time, &initial_time);
final_time = timespec_divide_by_int(final_time, NUMBER_OF_BYTES_TO_SIMULATE / 1024);
process_result(memory_copy_per_byte_ovhd, final_time);
final_time = timespec_divide_by_int(final_time, NUMBER_OF_BYTES_TO_SIMULATE / 1024);
process_result(memory_copy_per_byte_ovhd, final_time);
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
-static void *calibrate_thread_code(void *thread_arg)
+static void *fixed_abort_ovhd_thread_code(void *thread_arg)
protection_parameters_t protection_parameters;
frsh_signal_info_t signal_info_to_send;
protection_parameters_t protection_parameters;
frsh_signal_info_t signal_info_to_send;
memset(&protection_parameters, 0, sizeof(protection_parameters) );
memset(&signal_info_to_send, 0, sizeof(signal_info_to_send) );
memset(&protection_parameters, 0, sizeof(protection_parameters) );
memset(&signal_info_to_send, 0, sizeof(signal_info_to_send) );
+ memset(&mutex, 0, sizeof(mutex) );
thread_data = (thread_data_t *) thread_arg;
results = thread_data->results;
thread_data = (thread_data_t *) thread_arg;
results = thread_data->results;
+ PXW( fosa_mutex_init(&mutex, MUTEX_CEILING) );
+
/* Periodic loop */
/*****************/
/* Periodic loop */
/*****************/
protection_parameters.initialised = true;
}
protection_parameters.initialised = true;
}
+ PXW( fosa_mutex_lock(&mutex) );
+
/* We arm the jump_timer */
/* We arm the jump_timer */
- fosa_timer_arm(protection_parameters.jump_timer, false, &budget);
+ PXW( fosa_timer_arm(protection_parameters.jump_timer, false, &budget) );
/* This is the point where the jump returns */
fosa_long_jump_save_context(&context);
/* This is the point where the jump returns */
fosa_long_jump_save_context(&context);
{
/* HERE COMES THE WORK THAT CAN BE INTERRUPTED */
work_under_a_interruptible_budget();
{
/* HERE COMES THE WORK THAT CAN BE INTERRUPTED */
work_under_a_interruptible_budget();
+ PXW( fosa_timer_disarm(protection_parameters.jump_timer, NULL) );
+ PXW( fosa_mutex_unlock(&mutex) );
PERROR_AND_EXIT(FRSH_ERR_INTERNAL_ERROR, "The jump should always prevent us from arriving here\n");
}
PERROR_AND_EXIT(FRSH_ERR_INTERNAL_ERROR, "The jump should always prevent us from arriving here\n");
}
+
+ PXW( fosa_mutex_unlock(&mutex) );
+
/* E N D O F M E A S U R I N G H E R E */
/***************************************************/
fosa_clock_get_time(FOSA_CLOCK_REALTIME, &after_timestamp);
/* E N D O F M E A S U R I N G H E R E */
/***************************************************/
fosa_clock_get_time(FOSA_CLOCK_REALTIME, &after_timestamp);
- results->number_of_tries++;
decr_timespec(&after_timestamp, &before_timestamp);
decr_timespec(&after_timestamp, &minimum_budget_for_timer);
decr_timespec(&after_timestamp, &before_timestamp);
decr_timespec(&after_timestamp, &minimum_budget_for_timer);
incr_timespec(&results->total_interval, &interval);
}
incr_timespec(&results->total_interval, &interval);
}
}
// ------------------------------------------------------------------------------
}
// ------------------------------------------------------------------------------
results.average_interval.tv_nsec, results.number_of_tries);
}
results.average_interval.tv_nsec, results.number_of_tries);
}
// ------------------------------------------------------------------------------
static struct timespec timespec_divide_by_int(struct timespec numerator, long int denominator)
// ------------------------------------------------------------------------------
static struct timespec timespec_divide_by_int(struct timespec numerator, long int denominator)