Rev 1232 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
#include <kernel/kern.h>
#include "fsf_contract.h"
#include "fsf_server.h"
#include "func.h"
#include "event_header.h"
/* Activate task output */
#define TASK_OUTPUT
int cal_cycles
=0;
struct timespec zero_time
;
/* Soft and hard Task */
TASK test_task
(void *arg
)
{
long long i
,exec_cycles
= 0;
//int crit_start,crit_len;
//long long crit_start_cycles = 0, crit_len_cycles = 0;
//struct timespec next_time;
int act
= 0;
struct loader_task
*l
;
l
=&loader_task_list
[get_current_exec_task
()];
char tmp
[20];
while((l
->act_number
)>act
) {
//task_testcancel();
act
++;
#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
generic_set_next_activation
(&l
->act
[act
]);
exec_cycles
= (long long)(TIMESPEC2USEC
(&l
->exec
[act
])) * CALIBRATION_DELTA
/ cal_cycles
;
#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
for (i
=0;i
<exec_cycles
;i
++) calibration_func
();
//generic_task_endcycle();
}
return NULL
;
}
/* Mutex create */
/*
void loader_mutex_create(struct loader_task *start_loader_task)
{
struct loader_task *current = start_loader_task;
int i,res = 0;
PI_mutexattr_t a;
int init_array[MAX_MUTEX];
PI_mutexattr_default(a);
for (i = 0;i < MAX_MUTEX;i++) init_array[i] = 0;
while (current != NULL) {
if (current->crit_type == PAR_CRIT) {
if (init_array[current->resource] == 0) {
mutex_init(&mux_table[current->resource],&a);
init_array[current->resource] = 1;
res++;
}
}
current = current->next;
}
cprintf("Created %d mutex\n",res);
}
*/
/* Task create */
void loader_task_create
(struct loader_task
*start_loader_task
)
{
struct loader_task
*current
= &loader_task_list
[0];
//char tmp[30];
int i
=0,k
=0, total_task
;
int total_group
= 0;
//PID p;
total_task
= sizeof(loader_task_list
)/sizeof(struct loader_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
));
if (err
) {
cprintf
("Error fsf task creating\n");
sys_end
();
}
}
current
= &loader_task_list
[i
];
}
cprintf
("Created %d tasks\n",total_task
);
}
int main
()
{
struct loader_task
*start_loader_task
= &loader_task_list
[0];
struct timespec total
={20,0};
generic_calibrate_cycle
();
kern_gettime
(&zero_time
);
generic_fsfinit
();
//loader_mutex_create(start_loader_task);
loader_task_create
(start_loader_task
);
generic_set_simulation_time
(&total
);
return 0;
}