Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1200 → Rev 1201

/demos/trunk/loader/dosread.c
27,12 → 27,13
}
 
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)
{
char line_buf[1000];
char *pbuf = start;
int i,res,line_num,total_loader_task;
struct loader_task *current = NULL;
 
NULL_TIMESPEC(total);
 
47,10 → 48,11
}
pbuf += i+1;
line_buf[i] = 0;
res = line_parser(line_buf, line_num, total, start_loader_task);
res = line_parser(line_buf, line_num, total, &current);
if (res == 2) {
total_loader_task++;
start_loader_task = start_loader_task->next;
if (*start_loader_task == NULL) *start_loader_task = current;
current = current->next;
}
}
 
/demos/trunk/loader/parser.h
3,6 → 3,31
 
#include <kernel/kern.h>
 
#define PAR_TOTAL_EXEC_TIME 0
#define PAR_TIME 2
#define PAR_ACT_TYPE 3
#define PAR_TASK_NUMBER 4
#define PAR_EXEC_TYPE 5
#define PAR_TASK_TYPE 6
#define PAR_NOTHING 8
#define PAR_ERROR 10
#define PAR_FOUND 11
 
#define PAR_EXEC_CONST 12
#define PAR_EXEC_MEAN 13
#define PAR_EXEC_EXP 14
#define PAR_EXEC_EXP_MAX 15
 
#define PAR_ACT_SINGLE 16
#define PAR_ACT_PERIODIC 17
#define PAR_ACT_MEAN 18
#define PAR_ACT_EXP 19
#define PAR_ACT_EXP_MAX 20
 
#define PAR_TASK_NRT 21
#define PAR_TASK_HARD 22
#define PAR_TASK_SOFT 23
 
struct loader_task {
int number;
int task_level;
20,7 → 45,7
struct loader_task *next;
};
 
int line_parser(char *buf, int line_num, struct timespec *total, struct loader_task *last);
int line_parser(char *buf, int line_num, struct timespec *total, struct loader_task **last);
 
#endif
 
/demos/trunk/loader/dosread.h
5,6 → 5,6
 
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);
 
#endif
/demos/trunk/loader/loader.c
5,14 → 5,151
extern void *start;
extern void *end;
 
TASK nrt_test_task(void *arg)
{
 
while(1) {
 
}
return NULL;
 
}
 
TASK test_task(void *arg)
{
 
while(1) {
 
task_endcycle();
 
}
 
return NULL;
 
}
 
void loader_task_create(struct loader_task *start_loader_task)
{
 
struct loader_task *current = start_loader_task;
int i, total_task;
PID p;
 
total_task = 0;
 
while (current != NULL) {
 
for (i=0; i < current->number; i++) {
 
if (current->task_type == PAR_TASK_NRT) {
NRT_TASK_MODEL nrt;
nrt_task_default_model(nrt);
nrt_task_def_save_arrivals(nrt);
nrt_task_def_arg(nrt,(void *)(current));
nrt_task_def_ctrl_jet(nrt);
nrt_task_def_level(nrt,current->task_level);
nrt_task_def_group(nrt,1);
 
p = task_create("NRT",nrt_test_task,&nrt,NULL);
if (p == NIL) {
cprintf("Error nrt task creating\n");
sys_end();
}
 
total_task++;
 
}
 
if (current->task_type == PAR_TASK_HARD) {
HARD_TASK_MODEL ht;
hard_task_default_model(ht);
hard_task_def_arg(ht,(void *)(current));
hard_task_def_wcet(ht,TIMESPEC2USEC(&current->wcet));
hard_task_def_ctrl_jet(ht);
hard_task_def_level(ht,current->task_level);
hard_task_def_group(ht,1);
 
if (current->act_type == PAR_ACT_PERIODIC) {
hard_task_def_mit(ht,TIMESPEC2USEC(&current->act_par_2));
} else if (current->act_type != PAR_ACT_SINGLE) {
hard_task_def_mit(ht,TIMESPEC2USEC(&current->act_par_2));
hard_task_def_aperiodic(ht);
} else {
hard_task_def_mit(ht,TIMESPEC2USEC(&current->wcet)*100);
hard_task_def_aperiodic(ht);
}
p = task_create("HARD",test_task,&ht,NULL);
if (p == NIL) {
cprintf("Error hard task creating\n");
sys_end();
}
 
total_task++;
}
 
if (current->task_type == PAR_TASK_SOFT) {
SOFT_TASK_MODEL st;
soft_task_default_model(st);
soft_task_def_save_arrivals(st);
soft_task_def_arg(st,(void *)(current));
soft_task_def_met(st,TIMESPEC2USEC(&current->wcet));
soft_task_def_ctrl_jet(st);
soft_task_def_level(st,current->task_level);
soft_task_def_group(st,1);
if (current->act_type == PAR_ACT_PERIODIC) {
soft_task_def_period(st,TIMESPEC2USEC(&current->act_par_2));
} else if (current->act_type != PAR_ACT_SINGLE) {
soft_task_def_period(st,TIMESPEC2USEC(&current->act_par_2));
soft_task_def_aperiodic(st);
} else {
soft_task_def_period(st,TIMESPEC2USEC(&current->wcet)*100);
soft_task_def_aperiodic(st);
}
p = task_create("SOFT",test_task,&st,NULL);
if (p == NIL) {
cprintf("Error soft task creating\n");
sys_end();
}
 
total_task++;
}
 
}
 
current = current->next;
 
}
 
cprintf("Created %d tasks\n",total_task);
}
 
int main()
{
 
struct loader_task *start_loader_task = NULL;
struct timespec total;
struct timespec zero_time;
struct timespec end_time;
 
line_reader(start, end, &total, start_loader_task);
line_reader(start, end, &total, &start_loader_task);
 
loader_task_create(start_loader_task);
kern_gettime(&zero_time);
ADDTIMESPEC(&zero_time,&total,&end_time);
 
kern_event_post(&end_time,(void *)((void *)(sys_end)),NULL);
 
return 0;
 
}
/demos/trunk/loader/loadfile.txt
19,5 → 19,5
# ACT_EXP_MAX(START_TIME, MEAN, SIGMA, MAX)
 
TOTAL_EXEC_TIME:[10][0];
HARD:[1]:[1]:ACT_PERIODIC([0][0],[1][0]):[0][10000]:EXEC_CONST([0][1000]);
HARD:[0]:[1]:ACT_PERIODIC([0][0],[1][0]):[0][10000]:EXEC_CONST([0][1000]);
 
/demos/trunk/loader/parser.c
4,31 → 4,6
#include <stdio.h>
#include "parser.h"
 
#define PAR_TOTAL_EXEC_TIME 0
#define PAR_TIME 2
#define PAR_ACT_TYPE 3
#define PAR_TASK_NUMBER 4
#define PAR_EXEC_TYPE 5
#define PAR_TASK_TYPE 6
#define PAR_NOTHING 8
#define PAR_ERROR 10
#define PAR_FOUND 11
 
#define PAR_EXEC_CONST 12
#define PAR_EXEC_MEAN 13
#define PAR_EXEC_EXP 14
#define PAR_EXEC_EXP_MAX 15
 
#define PAR_ACT_SINGLE 16
#define PAR_ACT_PERIODIC 17
#define PAR_ACT_MEAN 18
#define PAR_ACT_EXP 19
#define PAR_ACT_EXP_MAX 20
 
#define PAR_TASK_NRT 21
#define PAR_TASK_HARD 22
#define PAR_TASK_SOFT 23
 
#define PARSER_DEBUG
 
static int find_break(char **buf, int find_type, struct timespec *time, int *val)
47,7 → 22,8
if (((char *)(*buf))[0] == '#' ||
((char *)(*buf))[0] == ';' ||
((char *)(*buf))[0] == 0 ||
((char *)(*buf))[0] == '\n') return PAR_FOUND;
((char *)(*buf))[0] == '\n' ||
((char *)(*buf))[0] == '\r') return PAR_FOUND;
break;
 
case PAR_TOTAL_EXEC_TIME:
189,7 → 165,7
* 1 -> total
* 2 -> new task-loader
*/
int line_parser(char *buf, int line_num, struct timespec *total, struct loader_task *last)
int line_parser(char *buf, int line_num, struct timespec *total, struct loader_task **last)
{
char *pbuf = buf;
struct timespec time;
222,7 → 198,7
if (ld == NULL) par_error(line_num);
ld->next = NULL;
last = ld;
*last = ld;
ld->task_type = val;