#include #include #include #include #include #include #include #include #include "ts.h" #include #include "returncode.h" #include "time_conversion.h" #include "processor_speed.h" #include "monano.h" #include "monano_data.h" #define NTHREAD 1 #define BILLION 1000000000.0 struct pthread_monano_t my_monano; struct pthread_monano_attr_t my_monano_attr; pthread_monano_id_t my_monano_id [NTHREAD]; /* function callback to specified the type of anomaly detected */ void* my_callback(int anomaly_number, pthread_monano_id_t id) { printf("Type anomaly : %d Anomaly is detected of thread number %d\n", anomaly_number, id); exit(0); return 0; } void* periodic_activation(void* arg){ int ego = *(int*)arg, status; /* Called by a thread to signal to MONANO that the thread has started its execution */ status=pthread_monano_signal_departure_time(&my_monano, my_monano_id[ego]); if(status<0) returncode("pthread_monano_signal_departure_time",status); /* Simulate an execution of code*/ status=pthread_monano_thread_execution(&my_monano, my_monano_id[ego]); if(status<0) returncode("thread_execution",status); /* Called by a thread to signal to MONANO that the thread has completed its execution */ status=pthread_monano_signal_end_time(&my_monano, my_monano_id[ego]); if(status<0) returncode("pthread_monano_signal_end_time",status); return 0; } void run_monano() { int status, i; int* ego; //struct timespec P1, WCET1, D1, P2, WCET2, D2; struct pthread_monano_attr_t tparam []={{99,{2,0},{4,0},{4,0}}}; /* Monano init and register */ pthread_monano_init(&my_monano); pthread_monano_attr_init(&my_monano_attr); pthread_monano_register_anomaly_callback(&my_monano, my_callback); for(i=0; i