#include #include #include #include #include #include #include #include "ts.h" #include #include "returncode.h" #include "time_conversion.h" #include "monano.h" #include "monano_data.h" #define NTHREAD 2 struct pthread_monano_t my_monano; struct pthread_monano_attr_t my_monano_attr; pthread_monano_id_t my_monano_id [NTHREAD]; 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, nb; int* ego; struct sched_param param; //struct timespec P1, WCET1, D1, P2, WCET2, D2; struct pthread_monano_attr_t tparam []={{99,{2,0},{3,0},{3,0}},{98,{2,0},{9,0},{9,0}}}; /* Upgrade main thread priority */ param.sched_priority=100; status=pthread_setschedparam(pthread_self(), SCHED_FIFO, ¶m); if(status<0) returncode("pthread_attr_setschedparam",status); /* Monano init and register */ pthread_monano_init(&my_monano); pthread_monano_attr_init(&my_monano_attr); nb=sizeof(tparam)/sizeof(tparam[0]); pthread_monano_register_anomaly_callback(&my_monano, my_callback); for(i=0; i