#include #include #include #include #include #include #include #include #include "returncode.h" #include "ts.h" #include "monano.h" #include "monano_data.h" #include "configure.h" int pthread_static_constraints_architecture1(pthread_monano_t t) { return (t.static_constraints[MONANO_STATIC_CONSTRAINTS_MONOCORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PARTITIONED]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PRECEDENCE_CONSTRAINTS]); } int pthread_static_constraints_architecture2(pthread_monano_t t) { return (t.static_constraints[MONANO_STATIC_CONSTRAINTS_MONOCORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PARTITIONED]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_NON_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_INDEPENDENT_TASKS]); } int pthread_static_constraints_architecture3(pthread_monano_t t) { return (t.static_constraints[MONANO_STATIC_CONSTRAINTS_MONOCORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PARTITIONED]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_DEADLINE_MONOTONIC]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SHARED_RESOURCES]); } int pthread_static_constraints_architecture4(pthread_monano_t t) { return (t.static_constraints[MONANO_STATIC_CONSTRAINTS_MONOCORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PARTITIONED]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_EDF_SCHEDULING]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_ASYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_INDEPENDENT_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SUSPENDED_TASKS]); } int pthread_static_constraints_architecture5(pthread_monano_t t) { return (t.static_constraints[MONANO_STATIC_CONSTRAINTS_MULTICORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_GLOBAL]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_ASYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_INDEPENDENT_TASKS]); } int pthread_static_constraints_architecture6(pthread_monano_t t) { return ( t.static_constraints[MONANO_STATIC_CONSTRAINTS_MULTICORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PARTITIONED]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_NON_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SHARED_RESOURCES]); } int pthread_static_constraints_architecture7(pthread_monano_t t) { return ( t.static_constraints[MONANO_STATIC_CONSTRAINTS_MULTICORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_GLOBAL]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_NON_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PRECEDENCE_CONSTRAINTS]); } int pthread_static_constraints_architecture8(pthread_monano_t t) { return ( t.static_constraints[MONANO_STATIC_CONSTRAINTS_MULTICORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_GLOBAL]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_DEADLINE_MONOTONIC]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_INDEPENDENT_TASKS]); } int pthread_static_constraints_architecture9(pthread_monano_t t) { return ( t.static_constraints[MONANO_STATIC_CONSTRAINTS_MULTICORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_GLOBAL]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_INDEPENDENT_TASKS]); } int pthread_static_constraints_architecture10(pthread_monano_t t) { return ( t.static_constraints[MONANO_STATIC_CONSTRAINTS_MULTICORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_GLOBAL]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_EDF_SCHEDULING]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_INDEPENDENT_TASKS]); } int pthread_static_constraints_architecture11(pthread_monano_t t) { return ( t.static_constraints[MONANO_STATIC_CONSTRAINTS_MULTICORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PARTITIONED]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_INDEPENDENT_TASKS]); } int pthread_static_constraints_architecture12(pthread_monano_t t) { return ( t.static_constraints[MONANO_STATIC_CONSTRAINTS_MONOCORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PARTITIONED]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_ASYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SHARED_RESOURCES]); } int pthread_static_constraints_architecture13(pthread_monano_t t) { return ( t.static_constraints[MONANO_STATIC_CONSTRAINTS_MONOCORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PARTITIONED]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_NON_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_ASYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_INDEPENDENT_TASKS]); } int pthread_static_constraints_architecture14(pthread_monano_t t) { return ( t.static_constraints[MONANO_STATIC_CONSTRAINTS_MONOCORE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PARTITIONED]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_FIXED_PRIORITY]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PREEMPTIVE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SYNCHRONOUS_RELEASE]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_PERIODIC_TASKS]&& t.static_constraints[MONANO_STATIC_CONSTRAINTS_SHARED_RESOURCES]); } int pthread_monano_verify_static_constraints_reduce_execution_time(pthread_monano_t t) { return ( pthread_static_constraints_architecture1(t)|| pthread_static_constraints_architecture2(t)|| pthread_static_constraints_architecture3(t)|| pthread_static_constraints_architecture4(t)|| pthread_static_constraints_architecture5(t)|| pthread_static_constraints_architecture6(t)|| pthread_static_constraints_architecture7(t) ); } int pthread_monano_verify_static_constraints_precedence_constraint_change(pthread_monano_t t) { return ( pthread_static_constraints_architecture1(t)|| pthread_static_constraints_architecture7(t) ); } int pthread_monano_verify_static_constraints_processor_speed_increase(pthread_monano_t t) { return ( pthread_static_constraints_architecture12(t)|| pthread_static_constraints_architecture13(t) ); } int pthread_monano_verify_static_constraints_period_change(pthread_monano_t t) { return ( pthread_static_constraints_architecture8(t)|| pthread_static_constraints_architecture9(t)|| pthread_static_constraints_architecture10(t)|| pthread_static_constraints_architecture11(t) ); } int pthread_monano_verify_static_constraints_priority_change(pthread_monano_t t) { return ( pthread_static_constraints_architecture1(t)|| pthread_static_constraints_architecture7(t) ); } int pthread_monano_verify_static_constraints_processor_number_increase(pthread_monano_t t) { return ( pthread_static_constraints_architecture7(t) ); } int pthread_monano_verify_static_constraints_delay_execution_time(pthread_monano_t t) { return ( pthread_static_constraints_architecture14(t) ); } /* Called by the monitored application to verify if the thread have miss its deadline */ int pthread_monano_verify_missed_deadline(pthread_monano_t* t, pthread_monano_id_t id){ if (ts_compare(ts_substract(t->attr[id].end_time, t->attr[id].last_release_time),t->attr[id].deadline)==1) printf("missed deadline of thread number %d \n", id); return 0; } /* Called by a thread to verify if the thread had change its priority level */ int pthread_monano_verify_priority_change(pthread_monano_t* t, pthread_monano_id_t id) { int policy, status; struct sched_param param; status=pthread_getschedparam(pthread_self(), &policy, ¶m); if (status<0) returncode("pthread_getschedparam",status); if (t->attr[id].priority!=param.sched_priority){ t->callback(PRIORITY_ANOMALY, id); } return 0; } /* Called by the monitored application to verify if execution time of a thread have been reduce */ int pthread_monano_verify_reduce_execution_time(pthread_monano_t* t, pthread_monano_id_t id){ printf("execution_time de %x : id = %d: %d:%d \n", pthread_self(), id, (int)t->attr[id].current_execution_time.tv_sec, (int)t->attr[id].current_execution_time.tv_nsec); pthread_monano_verify_missed_deadline(t,id); if (ts_compare(t->attr[id].current_execution_time, t->attr[id].wcet) < 0) t->callback(REDUCE_WCET_ANOMALY, id); return 0; } /* Called by the monitored application to signal if the precedence constraint of thread has been modified */ int pthread_monano_verify_precedence_constraint_change(pthread_monano_t* t, pthread_monano_id_t id){ int i; for(i=0; inb_precedencies; i++) { if(t->pthread_precedencies[i].destination==id) { if(pthread_monano_search_thread(dependencies_list,t->pthread_precedencies[i].source)==NULL) t->callback(DEPENDENCY_ANOMALY, i); } } return 0; } /* Called by the monitored application to signal to MONANO that the processor speed has change */ int pthread_monano_verify_processor_speed_increase(pthread_monano_t* t, pthread_monano_id_t id) { if (ts_compare(ts_substract(t->attr[id].end_time,t->attr[id].start_time), ts_divide(t->attr[id].wcet, 2)) < 0) processor_speed_list= pthread_monano_add_thread(processor_speed_list,id); if (pthread_monano_count_thread(processor_speed_list)==t->nb_thread) t->callback(SPEED_PROCESSOR_ANOMALY, id); return 0; } /* Called by the monitored application to verify if the thread had change its period */ int pthread_monano_verify_period_change(pthread_monano_t* t, pthread_monano_attr_t attr, pthread_monano_id_t id) { if(t->attr[id].change_period ==1) t->callback(PERIOD_ANOMALY, id); return 0; } /* Called by the monitored application to verify if its processor number has been change */ int pthread_monano_verify_processor_number_increase(pthread_monano_t* t) { if(t->change_nb_processors ==1) t->callback(NUMBER_PROCESSOR_ANOMALY, t->change_nb_processors); return 0; } /* Called by the monitored application to verify if delay time of a thread have been reduce */ int pthread_monano_verify_reduce_suspending_time(pthread_monano_t* t, pthread_monano_id_t id) { printf("execution_time de %x : id = %d: %d:%d \n", pthread_self(), id, (int)t->attr[id].selfsuspending_time.tv_sec, (int)t->attr[id].selfsuspending_time.tv_nsec); pthread_monano_verify_missed_deadline(t,id); if (ts_compare(t->attr[id].selfsuspending_time, t->attr[id].delay) < 0) t->callback(DELAY_WCET_ANOMALY, id); return 0; }