3,7 → 3,6 |
#include "fsf_contract.h" |
#include "fsf_server.h" |
#include "func.h" |
#include "event_header.h" |
|
/* Activate task output */ |
#define TASK_OUTPUT |
10,9 → 9,10 |
|
int cal_cycles=0; |
struct timespec zero_time; |
extern struct loader_task *loader_task_list; |
|
/* Soft and hard Task */ |
TASK test_task(void *arg) |
/* oneshot Soft and hard Task */ |
void *oneshot_task(void *arg) |
{ |
long long i,exec_cycles = 0; |
int act = 0; |
24,21 → 24,71 |
printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
#endif |
|
if (l->act_number > act+1) generic_set_next_activation(&l->act[act+1]); |
|
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles; |
|
for (i=0;i<exec_cycles;i++) calibration_func(); |
|
generic_task_endcycle(); |
|
return NULL; |
|
} |
|
void * periodic_task(void *arg) |
{ |
long long i,exec_cycles = 0; |
int act = 0; |
struct loader_task *l = (struct loader_task *)(arg); |
char tmp[20]; |
|
while(1) { |
|
#ifdef TASK_OUTPUT |
sprintf(tmp,"X[%06d]",act); |
printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
#endif |
|
act++; |
|
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles; |
|
for (i=0;i<exec_cycles;i++) calibration_func(); |
|
generic_task_endcycle(); |
|
act++; |
|
} |
return NULL; |
|
} |
|
void * back_task(void *arg) |
{ |
long long i,exec_cycles = 0; |
int act = 0; |
struct loader_task *l = (struct loader_task *)(arg); |
char tmp[20]; |
|
while(1) { |
|
#ifdef TASK_OUTPUT |
sprintf(tmp,"X[%06d]",act); |
printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
#endif |
|
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[0])) * CALIBRATION_DELTA / cal_cycles; |
|
for (i=0;i<exec_cycles;i++) calibration_func(); |
|
act++; |
|
} |
return NULL; |
|
} |
|
/* Task create */ |
/* this function create the task struct in memory */ |
|
void loader_task_create() |
{ |
|
47,20 → 97,31 |
int total_group = 0; |
|
total_task = sizeof(loader_task_list)/sizeof(struct loader_task); |
|
|
cprintf("Created 1 %d loader tasks\n",total_task); |
|
|
while (k < total_task) { |
k++; |
total_group++; |
current->group = total_group; |
|
|
for (i=0; i < current->number; i++) { |
|
|
pthread_t j; |
int err; |
|
err = generic_create_thread(current->server,&j,NULL,test_task,(void *)current,generic_get_task_model(current)); |
void *func=NULL; |
switch(current->task_type) { |
case PAR_TASK_OS: |
func=oneshot_task; |
break; |
case PAR_TASK_BT: |
func=back_task; |
break; |
case PAR_TASK_CT: |
func=periodic_task; |
break; |
} |
err = generic_create_thread(current->server,&j,NULL,func,(void *)current,generic_get_task_model(current)); |
if (err) { |
cprintf("Error fsf task creating\n"); |
sys_end(); |
78,7 → 139,7 |
} |
|
|
int main() |
int start_environment() |
{ |
|
struct timespec total = {20,0}; |
93,6 → 154,8 |
|
generic_set_simulation_time(&total); |
|
generic_start_simulation(); |
|
return 0; |
|
} |