116,6 → 116,7 |
// -------------------------------------------------- |
// -------------------------------------------------- |
|
pthread_t jposix = -1; |
pthread_t j1 = -1; |
pthread_t j2 = -1; |
pthread_t j3 = -1; |
128,6 → 129,43 |
|
pthread_mutex_t mux; |
|
void *posix(void *arg) |
{ |
struct timespec actual,end; |
int actpersecond,act; |
int cycle; |
|
act = 0; |
actpersecond = 0; |
cycle = 0; |
for (;;) { |
|
cycle++; |
kern_gettime(&actual); |
|
if (act == 0) { |
TIMESPEC_ASSIGN(&end,&actual); |
end.tv_sec++; |
} |
|
if (TIMESPEC_A_LT_B(&actual,&end)) { |
act++; |
} else { |
actpersecond = act; |
act = 0; |
} |
|
pthread_mutex_lock(&mux); |
printf_xy(0,exec_shadow,GREEN,"Thread %3d Act_per_Second = %8d cycle = %8d", |
exec_shadow,actpersecond,cycle); |
pthread_mutex_unlock(&mux); |
|
} |
|
return NULL; |
|
} |
|
void *star(void *arg) |
{ |
struct timespec actual,end; |
142,7 → 180,7 |
|
cycle++; |
kern_gettime(&actual); |
rec = GRUBSTAR_get_last_reclaiming(grubstar_level); |
rec = SERVER_get_last_reclaiming(grubstar_level); |
|
if (act == 0) { |
TIMESPEC_ASSIGN(&end,&actual); |
156,10 → 194,10 |
act = 0; |
} |
|
//pthread_mutex_lock(&mux); |
pthread_mutex_lock(&mux); |
printf_xy(0,exec_shadow,WHITE,"Thread %3d Act_per_Second = %8d cycle = %8d rec = %8d", |
exec_shadow,actpersecond,cycle,rec); |
//pthread_mutex_unlock(&mux); |
pthread_mutex_unlock(&mux); |
|
} |
|
181,7 → 219,7 |
|
cycle++; |
kern_gettime(&actual); |
rec = GRUBSTAR_get_last_reclaiming(grubstar_level); |
rec = SERVER_get_last_reclaiming(grubstar_level); |
|
if (act == 0) { |
TIMESPEC_ASSIGN(&end,&actual); |
195,10 → 233,10 |
act = 0; |
} |
|
//pthread_mutex_lock(&mux); |
pthread_mutex_lock(&mux); |
printf_xy(0,exec_shadow,RED,"Thread %3d Act_per_Second = %8d cycle = %8d rec = %8d", |
exec_shadow,actpersecond,cycle,rec); |
//pthread_mutex_unlock(&mux); |
pthread_mutex_unlock(&mux); |
|
task_endcycle(); |
|
208,19 → 246,16 |
|
} |
|
int keyinc = 5; |
|
void *edftask(void *arg) |
{ |
int i,j; |
long long j; |
while(1) { |
for (i=0;i<5; i++) { |
for (j=0; j<10; j++); |
//cputc('#'); |
//cputs((char *)(arg)); |
for (j=0; j<10000*keyinc; j++); |
task_endcycle(); |
} |
|
task_endcycle(); |
} |
|
return NULL; |
} |
|
228,12 → 263,13 |
void create() |
{ |
HARD_TASK_MODEL mhard; |
int err; |
|
struct timespec period1 = {0,100000000}; //30% |
struct timespec period2 = {0,200000000}; //15% |
struct timespec period1 = {0,90000000}; //30% |
struct timespec period2 = {0,300000000}; //20% |
struct timespec period3 = {0,300000000}; //10% |
struct timespec budget1 = {0,30000000}; |
struct timespec budget2 = {0,30000000}; |
struct timespec budget2 = {0,60000000}; |
struct timespec budget3 = {0,30000000}; |
|
PID t1, t2; |
242,8 → 278,8 |
|
hard_task_default_model(mhard); |
hard_task_def_ctrl_jet(mhard); |
hard_task_def_mit(mhard,30000); |
hard_task_def_wcet(mhard,3000); |
hard_task_def_mit(mhard,30000); //5% |
hard_task_def_wcet(mhard,1500); |
hard_task_def_arg(mhard,(void *)"X"); |
hard_task_def_group(mhard,1); |
hard_task_def_periodic(mhard); |
255,8 → 291,8 |
sys_end(); |
} |
|
hard_task_def_mit(mhard,30000); |
hard_task_def_wcet(mhard,3000); |
hard_task_def_mit(mhard,30000); //5% |
hard_task_def_wcet(mhard,1500); |
hard_task_def_arg(mhard,(void *)"Y"); |
t2 = task_create("Y", edftask, &mhard, NULL); |
if (t2 == NIL) { |
264,7 → 300,7 |
sys_end(); |
} |
|
//group_activate(1); |
group_activate(1); |
|
fsf_initialize_contract(&contract); |
|
277,10 → 313,13 |
fsf_set_contract_basic_parameters(&contract,&budget3,&period3,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
fsf_negotiate_contract(&contract,&server3); |
|
fsf_set_contract_basic_parameters(&contract,&budget1,&period1,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
fsf_set_contract_basic_parameters(&contract,&budget2,&period2,NULL,NULL,FSF_DEFAULT_WORKLOAD); |
fsf_set_local_scheduler_parameter(&contract, FSF_SCHEDULER_EDF); |
fsf_negotiate_contract(&contract,&server4); |
|
err = pthread_create(&jposix, NULL, posix, NULL); |
if (err) kern_printf("(Error creating posix task)"); |
|
kern_printf("(End Create)"); |
|
} |
288,43 → 327,49 |
int main(int argc, char **argv) |
{ |
|
char ch = 0; |
int err; |
HARD_TASK_MODEL ht; |
struct timespec endtimer; |
|
pthread_mutex_init(&mux,NULL); |
|
srand(kern_gettime(NULL)); |
create(); |
|
kern_gettime(&endtimer); |
endtimer.tv_sec += 20; |
kern_event_post(&endtimer, (void (*)(void *))(sys_end), NULL); |
|
do { |
ch = keyb_getch(BLOCK); |
err = fsf_create_thread(server1,&j1,NULL,star,NULL,NULL); |
kern_printf("(%d)",err); |
|
err = fsf_create_thread(server2,&j2,NULL,star,NULL,NULL); |
kern_printf("(%d)",err); |
|
err = fsf_create_thread(server3,&j3,NULL,star,NULL,NULL); |
kern_printf("(%d)",err); |
|
hard_task_default_model(ht); |
hard_task_def_mit(ht,200000); |
hard_task_def_wcet(ht,50000); |
err = fsf_create_thread(server4,&j4,NULL,periodic_star,NULL,&ht); |
kern_printf("(%d)",err); |
|
switch(ch) { |
case '1': |
err = fsf_create_thread(server1,&j1,NULL,star,NULL,NULL); |
kern_printf("(%d)",err); |
break; |
case '2': |
err = fsf_create_thread(server2,&j2,NULL,star,NULL,NULL); |
kern_printf("(%d)",err); |
break; |
case '3': |
err = fsf_create_thread(server3,&j3,NULL,star,NULL,NULL); |
kern_printf("(%d)",err); |
break; |
case '4': |
hard_task_default_model(ht); |
hard_task_def_mit(ht,200000); |
hard_task_def_wcet(ht,100000); |
err = fsf_create_thread(server4,&j4,NULL,periodic_star,NULL,&ht); |
kern_printf("(%d)",err); |
break; |
} |
/* hard_task_default_model(ht); |
hard_task_def_mit(ht,159000); |
hard_task_def_wcet(ht,50000); |
err = fsf_create_thread(server4,&j4,NULL,periodic_star,NULL,&ht); |
kern_printf("(%d)",err); |
*/ |
err = fsf_create_thread(server1,&j1,NULL,star,NULL,NULL); |
kern_printf("(%d)",err); |
|
err = fsf_create_thread(server2,&j2,NULL,star,NULL,NULL); |
kern_printf("(%d)",err); |
|
err = fsf_create_thread(server3,&j3,NULL,star,NULL,NULL); |
kern_printf("(%d)",err); |
|
} while(ch != ESC); |
|
sys_end(); |
|
return 0; |
|
} |