2,6 → 2,9 |
#include "parser.h" |
#include "dosread.h" |
|
#include "fsf_contract.h" |
#include "fsf_server.h" |
|
/* Memory pointers on loaded file */ |
extern void *start_file; |
extern void *end_file; |
17,10 → 20,6 |
|
struct timespec zero_time; |
int cal_cycles = 0; |
int cal_rit_start = 0; |
int cal_rit_calc_const = 0; |
int cal_rit_calc_mean = 0; |
int cal_rit_calc_gauss = 0; |
|
mutex_t mux_table[MAX_MUTEX]; |
|
34,11 → 33,9 |
int crit_start,crit_len; |
long long crit_start_cycles = 0, crit_len_cycles = 0; |
struct timespec next_time; |
static int act= 0; |
struct loader_task *l = (struct loader_task *)(arg); |
char tmp[20]; |
|
act++; |
|
act_1 = TIMESPEC2USEC(&l->act_par_2); |
act_2 = TIMESPEC2USEC(&l->act_par_3); |
act_3 = TIMESPEC2USEC(&l->act_par_4); |
74,16 → 71,15 |
} |
|
#ifdef TASK_OUTPUT |
printf_xy(exec_shadow % 20 + 60, exec_shadow / 20, GREEN, "R"); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, GREEN, "R[000000]"); |
#endif |
|
if (l->exec_type == PAR_EXEC_CONST) |
exec_cycles = (long long)(exec_1 - cal_rit_start - cal_rit_calc_const) |
* CALIBRATION_DELTA / cal_cycles; |
exec_cycles = (long long)(exec_1) * CALIBRATION_DELTA / cal_cycles; |
|
if (l->exec_type == PAR_EXEC_MEAN) |
exec_cycles = (long long)(exec_1 - cal_rit_start - cal_rit_calc_mean |
+ rand() % exec_2 - exec_2/2) * CALIBRATION_DELTA / cal_cycles; |
exec_cycles = (long long)(exec_1 + rand() % exec_2 - exec_2/2) |
* CALIBRATION_DELTA / cal_cycles; |
|
if (l->exec_type == PAR_EXEC_GAUSS) |
exec_cycles = 0; |
108,19 → 104,20 |
else { |
for (i=0;i<crit_start_cycles;i++) kern_gettime(NULL); |
#ifdef TASK_OUTPUT |
printf_xy(exec_shadow % 20 + 59, exec_shadow / 20, RED,"B"); |
sprintf(tmp,"B[%02d][%02d]",exec_shadow,l->resource); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, RED,tmp); |
#endif |
mutex_lock(&mux_table[l->resource]); |
for (i=0;i<crit_len_cycles;i++) kern_gettime(NULL); |
mutex_unlock(&mux_table[l->resource]); |
#ifdef TASK_OUTPUT |
printf_xy(exec_shadow % 20 + 59, exec_shadow / 20, GREEN,"R"); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, GREEN,"R[000000]"); |
#endif |
for (i=0;i<exec_cycles;i++) kern_gettime(NULL); |
} |
|
#ifdef TASK_OUTPUT |
printf_xy(exec_shadow % 20 + 60, exec_shadow / 20, WHITE, "E"); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, BLUE, "E[000000]"); |
#endif |
|
return NULL; |
137,12 → 134,10 |
int crit_start,crit_len; |
long long crit_start_cycles = 0, crit_len_cycles = 0; |
struct timespec next_time; |
static int act=0; |
int extra_rit, k; |
int act = 0; |
struct loader_task *l = (struct loader_task *)(arg); |
char tmp[20]; |
|
act++; |
|
act_1 = TIMESPEC2USEC(&l->act_par_2); |
act_2 = TIMESPEC2USEC(&l->act_par_3); |
act_3 = TIMESPEC2USEC(&l->act_par_4); |
151,8 → 146,6 |
exec_2 = TIMESPEC2USEC(&l->exec_par_2); |
exec_3 = TIMESPEC2USEC(&l->exec_par_3); |
|
extra_rit = cal_rit_start; |
|
if (l->crit_type == PAR_CRIT) { |
crit_1 = TIMESPEC2USEC(&l->crit_par_1); |
crit_2 = TIMESPEC2USEC(&l->crit_par_2); |
160,16 → 153,15 |
crit_4 = TIMESPEC2USEC(&l->crit_par_4); |
} |
|
k = 0; |
|
while(1) { |
|
task_testcancel(); |
|
act++; |
|
#ifdef TASK_OUTPUT |
k++; |
if (k > 15) k = 1; |
printf_xy(exec_shadow % 20 + 59, exec_shadow / 20, k,"X"); |
sprintf(tmp,"X[%06d]",act); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, GREEN, tmp); |
#endif |
|
if (l->act_type == PAR_ACT_MEAN) { |
186,12 → 178,11 |
} |
|
if (l->exec_type == PAR_EXEC_CONST) |
exec_cycles = (long long)(exec_1 - extra_rit - cal_rit_calc_const) |
* CALIBRATION_DELTA / cal_cycles; |
exec_cycles = (long long)(exec_1) * CALIBRATION_DELTA / cal_cycles; |
|
if (l->exec_type == PAR_EXEC_MEAN) |
exec_cycles = (long long)(exec_1 - extra_rit - cal_rit_calc_mean |
+ rand() % exec_2 - exec_2/2) * CALIBRATION_DELTA / cal_cycles; |
exec_cycles = (long long)(exec_1 + rand() % exec_2 - exec_2/2) |
* CALIBRATION_DELTA / cal_cycles; |
|
if (l->exec_type == PAR_EXEC_GAUSS) |
exec_cycles = 0; |
211,20 → 202,20 |
} |
} |
|
extra_rit = 0; |
|
if (l->crit_type == PAR_NO_CRIT) |
for (i=0;i<exec_cycles;i++) kern_gettime(NULL); |
else { |
for (i=0;i<crit_start_cycles;i++) kern_gettime(NULL); |
#ifdef TASK_OUTPUT |
printf_xy(exec_shadow % 20 + 59, exec_shadow / 20, k,"B"); |
sprintf(tmp,"B[%02d][%02d]",exec_shadow,l->resource); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, RED, tmp); |
#endif |
mutex_lock(&mux_table[l->resource]); |
for (i=0;i<crit_len_cycles;i++) kern_gettime(NULL); |
mutex_unlock(&mux_table[l->resource]); |
#ifdef TASK_OUTPUT |
printf_xy(exec_shadow % 20 + 59, exec_shadow / 20, k,"X"); |
sprintf(tmp,"X[%06d]",act); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, GREEN, tmp); |
#endif |
for (i=0;i<exec_cycles;i++) kern_gettime(NULL); |
} |
247,12 → 238,10 |
int crit_start,crit_len; |
long long crit_start_cycles = 0, crit_len_cycles = 0; |
struct timespec next_time; |
static int act=0; |
int extra_rit, k; |
int act = 0; |
struct loader_task *l = (struct loader_task *)(arg); |
char tmp[20]; |
|
act++; |
|
act_1 = TIMESPEC2USEC(&l->act_par_2); |
act_2 = TIMESPEC2USEC(&l->act_par_3); |
act_3 = TIMESPEC2USEC(&l->act_par_4); |
261,8 → 250,6 |
exec_2 = TIMESPEC2USEC(&l->exec_par_2); |
exec_3 = TIMESPEC2USEC(&l->exec_par_3); |
|
extra_rit = cal_rit_start; |
|
if (l->crit_type == PAR_CRIT) { |
crit_1 = TIMESPEC2USEC(&l->crit_par_1); |
crit_2 = TIMESPEC2USEC(&l->crit_par_2); |
270,16 → 257,15 |
crit_4 = TIMESPEC2USEC(&l->crit_par_4); |
} |
|
k = 0; |
|
while(1) { |
|
task_testcancel(); |
|
act++; |
|
#ifdef TASK_OUTPUT |
k++; |
if (k > 15) k = 1; |
printf_xy(exec_shadow % 20 + 59, exec_shadow / 20, k,"X"); |
sprintf(tmp,"X[%06d]",act); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, GREEN, tmp); |
#endif |
|
if (l->act_type == PAR_ACT_MEAN) { |
296,12 → 282,11 |
} |
|
if (l->exec_type == PAR_EXEC_CONST) |
exec_cycles = (long long)(exec_1 - extra_rit - cal_rit_calc_const) |
* CALIBRATION_DELTA / cal_cycles; |
exec_cycles = (long long)(exec_1) * CALIBRATION_DELTA / cal_cycles; |
|
if (l->exec_type == PAR_EXEC_MEAN) |
exec_cycles = (long long)(exec_1 - extra_rit - cal_rit_calc_mean |
+ rand() % exec_2 - exec_2/2) * CALIBRATION_DELTA / cal_cycles; |
exec_cycles = (long long)(exec_1 + rand() % exec_2 - exec_2/2) |
* CALIBRATION_DELTA / cal_cycles; |
|
if (l->exec_type == PAR_EXEC_GAUSS) |
exec_cycles = 0; |
321,20 → 306,20 |
} |
} |
|
extra_rit = 0; |
|
if (l->crit_type == PAR_NO_CRIT) |
for (i=0;i<exec_cycles;i++) kern_gettime(NULL); |
else { |
for (i=0;i<crit_start_cycles;i++) kern_gettime(NULL); |
#ifdef TASK_OUTPUT |
printf_xy(exec_shadow % 20 + 59, exec_shadow / 20, k,"B"); |
sprintf(tmp,"B[%02d][%02d]",exec_shadow,l->resource); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, RED, tmp); |
#endif |
mutex_lock(&mux_table[l->resource]); |
for (i=0;i<crit_len_cycles;i++) kern_gettime(NULL); |
mutex_unlock(&mux_table[l->resource]); |
#ifdef TASK_OUTPUT |
printf_xy(exec_shadow % 20 + 59, exec_shadow / 20, k,"X"); |
sprintf(tmp,"X[%06d]",act); |
printf_xy((exec_shadow % 5) * 9 + 34, exec_shadow / 5 + 5, GREEN, tmp); |
#endif |
for (i=0;i<exec_cycles;i++) kern_gettime(NULL); |
} |
350,9 → 335,6 |
{ |
long long i; |
struct timespec start,end,diff; |
int temp = 1234567; |
int temp_1 = 1234567; |
int temp_2 = 1234567; |
|
kern_cli(); |
kern_gettime(&start); |
365,36 → 347,6 |
|
cprintf("Calibration usec/[%d cycles] = %d\n",CALIBRATION_DELTA,cal_cycles); |
|
kern_cli(); |
kern_gettime(&start); |
temp = (long long)(temp_1) * CALIBRATION_DELTA / cal_cycles; |
kern_gettime(&end); |
kern_sti(); |
|
SUBTIMESPEC(&end,&start,&diff); |
cal_rit_calc_const = TIMESPEC2USEC(&diff); |
|
kern_cli(); |
kern_gettime(&start); |
temp = (long long)(temp_1 + rand() % temp_2 - temp_2/2) * CALIBRATION_DELTA / cal_cycles; |
kern_gettime(&end); |
kern_sti(); |
|
SUBTIMESPEC(&end,&start,&diff); |
cal_rit_calc_mean = TIMESPEC2USEC(&diff); |
|
kern_cli(); |
kern_gettime(&start); |
temp = TIMESPEC2USEC(&start); |
kern_gettime(&end); |
kern_sti(); |
|
SUBTIMESPEC(&end,&start,&diff); |
cal_rit_start = TIMESPEC2USEC(&diff) * 6 + cal_rit_calc_const; |
|
cprintf("Calibration delay start = %d const = %d mean = %d gauss = %d\n", |
cal_rit_start,cal_rit_calc_const,cal_rit_calc_mean,cal_rit_calc_gauss); |
|
return 0; |
|
} |
555,8 → 507,56 |
|
} |
|
if (current->task_type == PAR_TASK_FSF) { |
|
if (current->local_scheduler == PAR_POSIX) { |
pthread_t j; |
int err; |
err = fsf_create_thread(current->server,&j,NULL,back_task,(void *)current,NULL); |
if (err) { |
cprintf("Error fsf task creating\n"); |
sys_end(); |
} |
} |
|
if (current->local_scheduler == PAR_EDF) { |
HARD_TASK_MODEL ht; |
pthread_t j; |
int err; |
|
hard_task_default_model(ht); |
hard_task_def_mit(ht,TIMESPEC2USEC(¤t->deadline)); |
hard_task_def_wcet(ht,TIMESPEC2USEC(¤t->wcet)); |
err = fsf_create_thread(current->server,&j,NULL,test_task,(void *)current,&ht); |
if (err) { |
cprintf("Error fsf task creating\n"); |
sys_end(); |
} |
|
} |
|
if (current->local_scheduler == PAR_RM) { |
HARD_TASK_MODEL ht; |
pthread_t j; |
int err; |
|
hard_task_default_model(ht); |
hard_task_def_mit(ht,TIMESPEC2USEC(¤t->deadline)); |
hard_task_def_wcet(ht,TIMESPEC2USEC(¤t->wcet)); |
err = fsf_create_thread(current->server,&j,NULL,test_task,(void *)current,&ht); |
if (err) { |
cprintf("Error fsf task creating\n"); |
sys_end(); |
} |
|
} |
|
total_task++; |
|
} |
|
} |
|
cprintf("Task group %d created. Worst case BW = %d.%d \n", |
current->group,(int)( (long long)current->bandwidth * 100 / MAX_BANDWIDTH), |
(int)( (long long)current->bandwidth* 100000 / MAX_BANDWIDTH % 1000)); |
578,10 → 578,14 |
|
while (current != NULL) { |
|
if (current->task_type != PAR_TASK_FSF) { |
|
ADDTIMESPEC(&zero_time,¤t->act_par_1,&start_time); |
|
kern_event_post(&start_time, (void *)((void *)group_activate), (void *)(current->group)); |
|
} |
|
current = current->next; |
|
} |
588,6 → 592,8 |
|
} |
|
void fsfinit(void); |
|
int main() |
{ |
|
601,6 → 607,8 |
|
calibrate_cycle(); |
|
fsfinit(); |
|
loader_mutex_create(start_loader_task); |
|
loader_task_create(start_loader_task); |