#include "pmacros.h" #include "system.h" #include #include #include #include #include #include #include #include #include #include "returncode.h" #include "monano.h" #include "monano_data.h" #include "measure.h" #include "time_conversion.h" #include "task_parameter.h" #include "nthread.h" #include "benchmark.h" struct pthread_monano_t my_monano; pthread_monano_id_t my_monano_id[NTHREAD]; struct pthread_monano_attr_t tparam[CONFIGURE_MAXIMUM_MONANO_THREAD_NUMBER]; void* POSIX_Init(void *argument) { int status, i; int thread_number; long int hyperperiod; int* ego; struct timespec measure_ts_start; struct periodic_activation_parameters* param_active; struct pthread_monano_attr_t* task_param; struct benchmark_task_parameters* task_parameters; /* Monano init and register */ for(i=0; ipriority; tparam[i].period=task_param->period; tparam[i].wcet=task_param->wcet; tparam[i].deadline=task_param->deadline; tparam[i].preemption_delay=task_param->preemption_delay; tparam[i].selfsuspension=task_param->selfsuspension; /* create a monano periodic thread */ param_active = (struct periodic_activation_parameters*)malloc(sizeof(struct periodic_activation_parameters)); if (param_active == NULL) { printf("ERREUR MALLOC init.c"); exit(0); } benchmark_periodic_activation_parameter_init(param_active); param_active->ego=i; /* Set the system platform constraint*/ if (my_monano.static_constraints[MONANO_STATIC_CONSTRAINTS_NON_PREEMPTIVE]) param_active->non_preemptive=1; if (my_monano.static_constraints[MONANO_STATIC_CONSTRAINTS_PRECEDENCE_CONSTRAINTS]){ if(my_monano.nb_precedencies!=0){ for(int j=0;j< my_monano.nb_precedencies; j++) if (param_active->ego == my_monano.pthread_precedencies[j].destination) param_active->precedency_blocking=1; } } if (my_monano.static_constraints[MONANO_STATIC_CONSTRAINTS_ASYNCHRONOUS_RELEASE]){ if ((tparam[i].departure.tv_sec!=0)||(tparam[i].departure.tv_nsec!=0)) param_active->asynchronous=1; } if (my_monano.static_constraints[MONANO_STATIC_CONSTRAINTS_PREEMPTION_DELAY_TASKS]){ if ((tparam[i].preemption_delay.tv_sec!=0)||(tparam[i].preemption_delay.tv_nsec!=0)) param_active->preemption_delay=1; } if (my_monano.static_constraints[MONANO_STATIC_CONSTRAINTS_SELF_SUSPENSION_TASKS]){ if ((tparam[i].selfsuspension.tv_sec!=0)||(tparam[i].selfsuspension.tv_nsec!=0)) param_active->self_suspension=1; } measure_start(&measure_ts_start); status=pthread_monano_periodic_thread_create (&my_monano, tparam[i], benchmark_periodic_activation, &my_monano_id[i], param_active); measure_end(measure_ts_start, "end_time_periodic_thread_create"); if(status<0) returncode("pthread_monano_pthread_periodic_create",status); task_param++; } nanosleep(&stop,NULL); pthread_monano_stop(&my_monano); exit(0); return NULL; }