/demos/trunk/loader/lconst.h |
---|
14,6 → 14,9 |
#define PAR_EXEC_CONST 12 |
#define PAR_EXEC_MEAN 13 |
#define PAR_CONTRACT_SECTION 14 |
#define PAR_TASK_SECTION 15 |
#define PAR_ACT_SINGLE 16 |
#define PAR_ACT_PERIODIC 17 |
#define PAR_ACT_MEAN 18 |
/demos/trunk/loader/lparser.c |
---|
18,9 → 18,19 |
*buf += i; |
if (!strncmp(*buf,"END",3) && find_type == PAR_NOTHING) { |
*buf += 5; |
*buf += 3; |
return PAR_END; |
} |
if (!strncmp(*buf,"CONTRACT SECTION",16) && find_type == PAR_NOTHING) { |
*buf += 16; |
return PAR_CONTRACT_SECTION; |
} |
if (!strncmp(*buf,"TASK SECTION",12) && find_type == PAR_NOTHING) { |
*buf += 12; |
return PAR_TASK_SECTION; |
} |
i = 0; |
if (((char *)(*buf))[0] == '#' && find_type == PAR_NOTHING) { |
131,14 → 141,14 |
*val = PAR_POSIX; |
return PAR_FOUND; |
} |
if (!strncmp(*buf,"EDF",5)) { |
*buf += 5; |
*val = PAR_ACT_PERIODIC; |
if (!strncmp(*buf,"EDF",3)) { |
*buf += 3; |
*val = PAR_EDF; |
return PAR_FOUND; |
} |
if (!strncmp(*buf,"RM",2)) { |
*buf += 2; |
*val = PAR_ACT_MEAN; |
*val = PAR_RM; |
return PAR_FOUND; |
} |
return PAR_ERROR; |
192,7 → 202,7 |
* 2 -> new task-loader |
* 3 -> end file |
*/ |
int line_parser(char **pbuf, int line_num, struct timespec *total, struct loader_task **last) |
int line_parser_task(char **pbuf, int line_num, struct loader_task **last) |
{ |
struct timespec time; |
struct loader_task *ld = NULL; |
202,19 → 212,6 |
if (res == PAR_FOUND) return 0; |
if (res == PAR_END) return 3; |
res = find_break(pbuf,PAR_TOTAL_EXEC_TIME, &time, &val); |
if (res == PAR_FOUND) { |
NULL_TIMESPEC(total); |
res = find_break(pbuf, PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
TIMESPEC_ASSIGN(total,&time); |
#ifdef PARSER_DEBUG |
printf("TOTAL EXEC TIME SEC = %ld NSEC = %ld\n",total->tv_sec,total->tv_nsec); |
#endif |
return 1; |
} else par_error(line_num); |
} |
res = find_break(pbuf,PAR_TASK_TYPE, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
301,6 → 298,16 |
} else par_error(line_num); |
} |
if (ld->act_type != PAR_ACT_SINGLE && ld->act_type != PAR_ACT_PERIODIC) { |
res = find_break(pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld->act_par_3,&time); |
} else par_error(line_num); |
} |
#ifdef PARSER_DEBUG |
printf(")\n"); |
#endif |
330,6 → 337,16 |
TIMESPEC_ASSIGN(&ld->exec_par_2,&time); |
} else par_error(line_num); |
} |
if (ld->exec_type != PAR_EXEC_CONST) { |
res = find_break(pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&ld->exec_par_3,&time); |
} else par_error(line_num); |
} |
#ifdef PARSER_DEBUG |
printf(")\n"); |
392,3 → 409,77 |
} |
int line_parser_contract(char **pbuf, int line_num, struct timespec *total, struct loader_contract **last) |
{ |
struct timespec time; |
struct loader_contract *lc = NULL; |
int val, res; |
res = find_break(pbuf, PAR_NOTHING, &time, &val); |
if (res == PAR_FOUND) return 0; |
if (res == PAR_END) return 3; |
res = find_break(pbuf,PAR_TOTAL_EXEC_TIME, &time, &val); |
if (res == PAR_FOUND) { |
NULL_TIMESPEC(total); |
res = find_break(pbuf, PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
TIMESPEC_ASSIGN(total,&time); |
#ifdef PARSER_DEBUG |
printf("TOTAL EXEC TIME SEC = %ld NSEC = %ld\n",total->tv_sec,total->tv_nsec); |
#endif |
return 1; |
} else par_error(line_num); |
} |
res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
printf("CONTRACT [%d]",val); |
#endif |
lc = malloc(sizeof(struct loader_contract)); |
if (lc == NULL) par_error(line_num); |
lc->next = NULL; |
*last = lc; |
lc->number = val; |
} else par_error(line_num); |
res = find_break(pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&lc->cmin,&time); |
} else par_error(line_num); |
res = find_break(pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&lc->tmax,&time); |
} else par_error(line_num); |
res = find_break(pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
printf(",[%ld][%ld]",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&lc->cmax,&time); |
} else par_error(line_num); |
res = find_break(pbuf,PAR_TIME, &time, &val); |
if (res == PAR_FOUND) { |
#ifdef PARSER_DEBUG |
printf(",[%ld][%ld]\n",time.tv_sec,time.tv_nsec/1000); |
#endif |
TIMESPEC_ASSIGN(&lc->tmin,&time); |
} else par_error(line_num); |
return 2; |
} |
/demos/trunk/loader/shark.c |
---|
97,10 → 97,10 |
ADDTIMESPEC(&zero_time, &l->act[0], &end_time); |
l->act_current++; |
kern_event_post(&end_time,(void *)((void *)(loader_task_activate)),l); |
l=&loader_task_list[i]; |
} |
i++; |
l=&loader_task_list[i]; |
} |
/demos/trunk/loader/event_gen.c |
---|
228,7 → 228,8 |
char task_name[100]; |
char act_type,exec_type; |
struct timespec total_time; |
struct loader_task *start_loader_task, *current; |
struct loader_task *start_loader_task = NULL, *current_t; |
struct loader_contract *start_loader_contract = NULL, *current_c; |
int err,ldnum; |
int total_task_number; |
240,23 → 241,24 |
printf("Parsing file\n"); |
line_reader(start, end, &total_time, &start_loader_task); |
line_reader(start, end, &total_time, &start_loader_task, &start_loader_contract); |
srandom(12354132); |
write_struct(); |
current = start_loader_task; |
current_t = start_loader_task; |
ldnum = 1; |
while(current != NULL) { |
while(current_t != NULL) { |
sprintf(current->name,"ltask%d",ldnum); |
current->group = ldnum; |
sprintf(current_t->name,"ltask%d",ldnum); |
current_t->group = ldnum; |
ldnum++; |
switch (current->act_type) { |
switch (current_t->act_type) { |
case PAR_ACT_SINGLE: |
err = write_single_act(&total_time,current); |
err = write_single_act(&total_time,current_t); |
if (err != 0) { |
printf("Error writing activation header\n"); |
exit(1); |
263,7 → 265,7 |
} |
break; |
case PAR_ACT_PERIODIC: |
err = write_periodic_act(&total_time,current); |
err = write_periodic_act(&total_time,current_t); |
if (err != 0) { |
printf("Error writing activation header\n"); |
exit(1); |
270,7 → 272,7 |
} |
break; |
case PAR_ACT_MEAN: |
err = write_mean_act(&total_time,current); |
err = write_mean_act(&total_time,current_t); |
if (err != 0) { |
printf("Error writing activation header\n"); |
exit(1); |
278,9 → 280,9 |
break; |
} |
switch (current->exec_type) { |
switch (current_t->exec_type) { |
case PAR_EXEC_CONST: |
err = write_exec_const(current); |
err = write_exec_const(current_t); |
if (err != 0) { |
printf("Error writing exec header\n"); |
exit(1); |
287,7 → 289,7 |
} |
break; |
case PAR_EXEC_MEAN: |
err = write_exec_mean(current); |
err = write_exec_mean(current_t); |
if (err != 0) { |
printf("Error writing exec header\n"); |
exit(1); |
295,20 → 297,20 |
break; |
} |
current = current->next; |
current_t = current_t->next; |
} |
write_basic_par_start(); |
total_task_number = 0; |
current = start_loader_task; |
while(current != NULL) { |
current_t = start_loader_task; |
while(current_t != NULL) { |
write_basic_par_start(); |
write_basic_par(current_t); |
write_basic_par(current); |
current_t = current_t->next; |
current = current->next; |
total_task_number++; |
} |
/demos/trunk/loader/load.txt |
---|
1,3 → 1,11 |
# CONTRACT SECTION |
# |
# CONTRACT NUMBER:CMIN:TMAX:CMAX:TMIN:WORKLOAD |
# |
# CONTRACT NUMBER IS THE SERVER NUMBER |
# |
# TASK SECTION |
# |
# TASK TYPE:SERVER NUMBER:LOCAL SCHEDULER:NUMBER OF TASK:DEADLINE:WCET:TASK ACT TYPE (PAR1,PAR2,...): |
# :TASK EXEC TYPE (PAR1,PAR2,...):CRITICAL SESSION (PAR1,PAR2,PAR3,PAR4); |
# |
24,7 → 32,27 |
TOTAL_EXEC_TIME:[20][0]; |
BT:[0]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([0][0]): |
CONTRACT SECTION |
[0]:[0][3000]:[0][10000]:[0][3000]:[0][10000]; |
[1]:[0][6000]:[0][30000]:[0][6000]:[0][30000]; |
[2]:[0][3000]:[0][30000]:[0][3000]:[0][30000]; |
[3]:[0][6000]:[0][30000]:[0][6000]:[0][30000]; |
END |
TASK SECTION |
BT:[0]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([3][0]): |
:EXEC_CONST([0][16000]):CRIT([1],[0][500],[0][1000],[0][5000],[0][10000]); |
BT:[1]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([4][0]): |
:EXEC_CONST([0][16000]):CRIT([2],[0][500],[0][1000],[0][5000],[0][10000]); |
BT:[2]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([5][0]): |
:EXEC_CONST([0][16000]):CRIT([3],[0][500],[0][1000],[0][5000],[0][10000]); |
CT:[3]:EDF:[1]:[1][0]:[0][100000]:ACT_PERIODIC([6][0],[1][0]): |
:EXEC_CONST([0][20000]):CRIT([4],[0][500],[0][1000],[0][5000],[0][10000]); |
END |
/demos/trunk/loader/lparser.h |
---|
39,7 → 39,22 |
}; |
int line_parser(char **buf, int line_num, struct timespec *total, struct loader_task **last); |
struct loader_contract { |
int number; |
struct timespec cmin; |
struct timespec tmax; |
struct timespec cmax; |
struct timespec tmin; |
int workload; |
struct loader_contract *next; |
}; |
int line_parser_contract(char **buf, int line_num, struct timespec *total_time, struct loader_contract **last); |
int line_parser_task(char **buf, int line_num, struct loader_task **last); |
#endif |
/demos/trunk/loader/event_gen.h |
---|
22,3 → 22,14 |
}; |
struct loader_contract { |
int number; |
struct timespec cmin; |
struct timespec tmax; |
struct timespec cmax; |
struct timespec tmin; |
int workload; |
} |
/demos/trunk/loader/lread.c |
---|
28,32 → 28,57 |
} |
int line_reader(void *start_file, void *end_file, struct timespec *total, struct loader_task **start_loader_task) |
int line_reader(void *start_file, void *end_file, struct timespec *total, |
struct loader_task **start_loader_task, struct loader_contract **start_loader_contract) |
{ |
char *pbuf = start_file; |
int res,line_num,total_loader_task; |
struct loader_task *current = NULL; |
int res,line_num,total_loader_task,total_loader_contract; |
struct loader_task *current_t = NULL; |
struct loader_contract *current_c = NULL; |
NULL_TIMESPEC(total); |
line_num = 0; |
total_loader_task = 0; |
total_loader_contract = 0; |
while ((void *)(pbuf) < end_file) { |
line_num++; |
if (*start_loader_contract == NULL) |
res = line_parser_contract(&pbuf, line_num, total, ¤t_c); |
else |
res = line_parser_contract(&pbuf, line_num, total, ¤t_c->next); |
if (res == 2) { |
total_loader_contract++; |
if (*start_loader_contract == NULL) |
*start_loader_contract = current_c; |
else |
current_c = current_c->next; |
} |
if (res == 3) break; |
} |
while ((void *)(pbuf) < end_file) { |
line_num++; |
if (*start_loader_task == NULL) |
res = line_parser(&pbuf, line_num, total, ¤t); |
res = line_parser_task(&pbuf, line_num, ¤t_t); |
else |
res = line_parser(&pbuf, line_num, total, ¤t->next); |
res = line_parser_task(&pbuf, line_num, ¤t_t->next); |
if (res == 2) { |
total_loader_task++; |
if (*start_loader_task == NULL) |
*start_loader_task = current; |
*start_loader_task = current_t; |
else |
current = current->next; |
current_t = current_t->next; |
} |
if (res == 3) break; |
61,6 → 86,7 |
} |
printf("Total decoded lines %d\n",line_num); |
printf("Total loader contract %d\n",total_loader_contract); |
printf("Total loader task %d\n",total_loader_task); |
printf("Simulation time sec = %ld usec = %ld\n",total->tv_sec,total->tv_nsec/1000); |
/demos/trunk/loader/makefile |
---|
12,7 → 12,7 |
include $(BASE)/config/example.mk |
newloader: |
make -f $(SUBMAKE) APP=newloader INIT= OTHEROBJS="fsfinit.o initfile.o shark.o eventc.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __FIRST__" |
#make -f $(SUBMAKE) APP=newloader INIT= OTHEROBJS="fsfinit.o initfile.o shark.o eventc.o" OTHERINCL= SHARKOPT="__OLDCHAR__ __FIRST__" |
gcc -o lread.o -c lread.c |
gcc -o lparser.o -c lparser.c |
gcc -o event_gen event_gen.c lparser.o lread.o |
/demos/trunk/loader/lread.h |
---|
5,6 → 5,7 |
int dos_preload(char *file_name, long max_size, void **start, void **end); |
int line_reader(void *start, void *end, struct timespec *total, struct loader_task **start_loader_task); |
int line_reader(void *start, void *end, struct timespec *total, |
struct loader_task **start_loader_task, struct loader_contract **start_loader_contract); |
#endif |