#include #include #include #include #include #include #include #include "ts.h" #include #include "monano.h" #include "returncode.h" /* pthread_monano_attr */ /* pthread_monano_attr attribute accessor functions */ int pthread_monano_attr_setpriority(pthread_monano_attr_t* attr,int prio) { attr->priority=prio; return 0; } int pthread_monano_attr_setwcet(pthread_monano_attr_t* attr, struct timespec w) { attr->wcet=w; return 0; } int pthread_monano_attr_setdeadline(pthread_monano_attr_t* attr, struct timespec d) { attr->deadline=d; return 0; } int pthread_monano_attr_setperiod(pthread_monano_attr_t* attr, struct timespec p) { attr->period=p; attr->change_period=1; return 0; } int pthread_monano_attr_setdeparture(pthread_monano_attr_t* attr, struct timespec dep) { attr->departure=dep; return 0; } int pthread_monano_attr_setdelay(pthread_monano_attr_t* attr, struct timespec del) { attr->delay=del; return 0; } int pthread_monano_attr_setstart_time(pthread_monano_attr_t* attr, struct timespec stime) { attr->start_time = stime; return 0; } int pthread_monano_attr_setend_time(pthread_monano_attr_t* attr, struct timespec etime) { attr->end_time = etime; return 0; } int pthread_monano_attr_setdeparture_selfsuspension(pthread_monano_attr_t* attr, struct timespec dstime) { attr->departure_selfsuspension=dstime; return 0; } int pthread_monano_attr_setpreemption_time(pthread_monano_attr_t* attr, struct timespec ptime) { attr->preemption_time=ptime; return 0; } /* pthread_monano_attr attribute modifier functions */ int pthread_monano_attr_getpriority(pthread_monano_attr_t attr) { return attr.priority; } struct timespec pthread_monano_attr_getwcet(pthread_monano_attr_t attr) { return attr.wcet; } struct timespec pthread_monano_attr_getdeadline(pthread_monano_attr_t attr) { return attr.deadline; } struct timespec pthread_monano_attr_getperiod(pthread_monano_attr_t attr) { return attr.period; } struct timespec pthread_monano_attr_getdeparture(pthread_monano_attr_t attr) { return attr.departure; } struct timespec pthread_monano_attr_getdelay(pthread_monano_attr_t attr) { return attr.delay; } struct timespec pthread_monano_attr_getstart_time(pthread_monano_attr_t attr) { return attr.start_time; } struct timespec pthread_monano_attr_getend_time(pthread_monano_attr_t attr) { return attr.end_time; } struct timespec pthread_monano_attr_getdeparture_selfsuspension(pthread_monano_attr_t attr) { return attr.departure_selfsuspension; } struct timespec pthread_monano_attr_getpreemption_time(pthread_monano_attr_t attr) { return attr.preemption_time; } /* pthread_monano_precedency attribute Accessors functions*/ int pthread_monano_precedency_attr_setsource(pthread_monano_precedency_t* pred, pthread_monano_id_t s) { pred->source = s; return 0; } int pthread_monano_precedency_attr_setdestination(pthread_monano_precedency_t* pred, pthread_monano_id_t d) { pred->destination =d; return 0; } /* pthread_monano_precedency attribute modifiers functions*/ pthread_monano_id_t pthread_monano_precedency_attr_getsource(pthread_monano_precedency_t pred) { return pred.source; } pthread_monano_id_t pthread_monano_precedency_attr_getdestination(pthread_monano_precedency_t pred) { return pred.destination; } /* pthread_monano_static constraints attribute accessors and modifiers functions */ bool pthread_monano_attr_getstatic_constraints(pthread_monano_t* t, int staticconstraint) { return t->static_constraints[staticconstraint]; } int pthread_monano_attr_setstatic_constraints(pthread_monano_t* t, int staticconstraint) { t->static_constraints[staticconstraint]=true; return 0; } /* pthread_monano_processor_number attribute accessors and modifiers functions */ int pthread_monano_attr_getnb_processors(pthread_monano_t* t) { return t->nb_processors; } int pthread_monano_attr_setnb_processors(pthread_monano_t* t, int processornumber) { t->nb_processors = processornumber; t->change_nb_processors = 1; return 0; } /* initialize monano thread attribute */ int pthread_monano_attr_init(pthread_monano_attr_t *attr){ struct timespec init; init.tv_sec=0; init.tv_nsec=0; attr->priority=0; attr->change_period=0; attr->period=init; attr->wcet=init; attr->deadline=init; attr->departure=init; attr->delay=init; attr->start_time=init; attr->end_time=init; attr->last_remaining_preempted=init; attr->blocking_time=init; attr->start_blocking_time=init; attr->current_execution_time=init; attr->preemption_time=init; attr->departure_selfsuspension=init; attr->selfsuspending_time=init; attr->start_selfsuspending_time=init; return 0; }