/demos/trunk/loader/func.h |
---|
1,33 → 1,8 |
#ifndef FUNC_H |
#define FUNC_H |
struct loader_task { |
char name[20]; |
int number; |
int group; |
int server; |
int local_scheduler; |
struct timespec deadline; |
struct timespec wcet; |
int act_number; |
struct timespec *act; |
struct timespec *exec; |
}; |
#include "eventc.h" |
#define LOADER_POSIX_SCHEDULER 0 |
#define LOADER_EDF_SCHEDULER 1 |
#define LOADER_RM_SCHEDULER 2 |
#define LOADER_MPEGSTAR_SCHEDULER 3 |
/* Calibration Loops */ |
#define CALIBRATION_DELTA 10000 |
extern int cal_cycles; |
extern struct timespec zero_time; |
#define SHARK |
#if defined SHARK |
#include "shark.h" |
39,10 → 14,13 |
#define generic_set_next_activation set_next_activation |
#define generic_set_simulation_time set_simulation_time |
#define generic_get_task_model get_task_model |
#define generic_start_simulation start_simulation |
#define generic_fsfinit() fsfinit() |
#define generic_task_endcycle() ; |
#define generic_task_endcycle() task_endcycle() |
#endif |
#include "func.h" |
#endif |
/demos/trunk/loader/initfile.c |
---|
51,15 → 51,10 |
#include "modules/pi.h" |
#include "modules/pc.h" |
#include "dosread.h" |
#define TICK 0 |
#define RRTICK 10000 |
void *start_file; |
void *end_file; |
TIME __kernel_register_levels__(void *arg) |
{ |
struct multiboot_info *mb = (struct multiboot_info *)arg; |
80,8 → 75,6 |
PTHREAD_register_module(1, 0, 1); |
//dos_preload("loadfile.txt",100000,&start_file,&end_file); |
return TICK; |
} |
96,3 → 89,10 |
return (void *)0; |
} |
int main() { |
return start_environment(); |
} |
/demos/trunk/loader/lconst.h |
---|
0,0 → 1,33 |
#define PAR_TOTAL_EXEC_TIME 0 |
#define PAR_TIME 1 |
#define PAR_ACT_TYPE 2 |
#define PAR_TASK_NUMBER 3 |
#define PAR_EXEC_TYPE 4 |
#define PAR_TASK_TYPE 5 |
#define PAR_NOTHING 6 |
#define PAR_DEADLINE 7 |
#define PAR_ERROR 8 |
#define PAR_FOUND 9 |
#define PAR_CRIT_SESSION 10 |
#define PAR_END 11 |
#define PAR_EXEC_CONST 12 |
#define PAR_EXEC_MEAN 13 |
#define PAR_ACT_SINGLE 16 |
#define PAR_ACT_PERIODIC 17 |
#define PAR_ACT_MEAN 18 |
#define PAR_TASK_OS 21 |
#define PAR_TASK_CT 22 |
#define PAR_TASK_BT 23 |
#define PAR_NO_CRIT 26 |
#define PAR_CRIT 27 |
#define PAR_LOCAL_SCHEDULER 29 |
#define PAR_POSIX 30 |
#define PAR_EDF 31 |
#define PAR_RM 32 |
#define PAR_FSF_SERVER 33 |
/demos/trunk/loader/shark.c |
---|
1,8 → 1,9 |
#include <kernel/kern.h> |
#include "func.h" |
extern int cal_cycles; |
extern struct timespec zero_time; |
extern struct loader_task *loader_task_list; |
/* Delay Calibration */ |
int calibrate_cycle() |
{ |
24,7 → 25,7 |
} |
void *get_task_model(struct loader_task *current) { |
if (current->local_scheduler == LOADER_POSIX_SCHEDULER) { |
if (current->local_scheduler == PAR_POSIX) { |
static NRT_TASK_MODEL nrt; |
nrt_task_default_model(nrt); |
36,7 → 37,7 |
} |
if (current->local_scheduler == LOADER_EDF_SCHEDULER) { |
if (current->local_scheduler == PAR_EDF) { |
static HARD_TASK_MODEL ht; |
hard_task_default_model(ht); |
48,7 → 49,7 |
} |
if (current->local_scheduler == LOADER_RM_SCHEDULER) { |
if (current->local_scheduler == PAR_RM) { |
static HARD_TASK_MODEL ht; |
hard_task_default_model(ht); |
71,13 → 72,48 |
} |
void set_next_activation(struct timespec *next) { |
int calibration_func() { |
return kern_gettime(NULL); |
} |
void start_simulation() { |
int i, total_task; |
struct loader_task *l; |
struct timespec end_time; |
ADDTIMESPEC(&zero_time,next,&end_time); |
kern_event_post(&end_time,(void *)((void *)(task_activate(exec_shadow))),NULL); |
total_task = sizeof(loader_task_list)/sizeof(struct loader_task); |
i = 0; |
while (i<total_task) { |
if (l->act_number>0) { |
ADDTIMESPEC(&zero_time, &l->act[0], &end_time); |
l->act_current++; |
kern_event_post(&end_time,loader_task_activate,&l); |
i++; |
l=&loader_task_list[i]; |
} |
} |
} |
int calibration_func() { |
return kern_gettime(NULL); |
void loader_task_activate(struct loader_task *l) { |
struct timespec actual_time,end_time; |
kern_gettime(&actual_time); |
group_activate(l->group); |
if (l->act_number > l->act_current) { |
ADDTIMESPEC(&actual_time, &l->act[l->act_current], &end_time); |
l->act_current++; |
kern_event_post(&end_time,loader_task_activate,&l); |
} |
} |
/demos/trunk/loader/lparser.h |
---|
1,40 → 1,8 |
#ifndef __LPARSER_H__ |
#define __LPARSER_H__ |
#define PAR_TOTAL_EXEC_TIME 0 |
#define PAR_TIME 1 |
#define PAR_ACT_TYPE 2 |
#define PAR_TASK_NUMBER 3 |
#define PAR_EXEC_TYPE 4 |
#define PAR_TASK_TYPE 5 |
#define PAR_NOTHING 6 |
#define PAR_DEADLINE 7 |
#define PAR_ERROR 8 |
#define PAR_FOUND 9 |
#define PAR_CRIT_SESSION 10 |
#define PAR_END 11 |
#include "lconst.h" |
#define PAR_EXEC_CONST 12 |
#define PAR_EXEC_MEAN 13 |
#define PAR_ACT_SINGLE 16 |
#define PAR_ACT_PERIODIC 17 |
#define PAR_ACT_MEAN 18 |
#define PAR_TASK_OS 21 |
#define PAR_TASK_CT 22 |
#define PAR_TASK_BT 23 |
#define PAR_NO_CRIT 26 |
#define PAR_CRIT 27 |
#define PAR_LOCAL_SCHEDULER 29 |
#define PAR_POSIX 30 |
#define PAR_EDF 31 |
#define PAR_RM 32 |
#define PAR_FSF_SERVER 33 |
struct loader_task { |
char name[20]; |
/demos/trunk/loader/shark.h |
---|
1,10 → 1,15 |
#ifndef SHARK_H |
#define SHARK_H |
#include "kernel/kern.h" |
#include "event_gen.h" |
int calibrate_cycle(); |
void start_simulation(); |
void *get_task_model(struct loader_task *current); |
void set_simulation_time (struct timespec *total); |
void set_next_activation(struct timespec *next); |
void loader_task_activate(struct loader_task *l); |
int calibration_func(); |
#endif |
/demos/trunk/loader/event_gen.h |
---|
1,6 → 1,6 |
/* Generic Struct for loader task */ |
#include <stdlib.h> |
#include "lconst.h" |
struct loader_task { |
22,5 → 22,3 |
}; |
struct loader_task loader_task_list[]; |
/demos/trunk/loader/newloader.c |
---|
3,7 → 3,6 |
#include "fsf_contract.h" |
#include "fsf_server.h" |
#include "func.h" |
#include "event_header.h" |
/* Activate task output */ |
#define TASK_OUTPUT |
10,9 → 9,10 |
int cal_cycles=0; |
struct timespec zero_time; |
extern struct loader_task *loader_task_list; |
/* Soft and hard Task */ |
TASK test_task(void *arg) |
/* oneshot Soft and hard Task */ |
void *oneshot_task(void *arg) |
{ |
long long i,exec_cycles = 0; |
int act = 0; |
24,21 → 24,71 |
printf_xy((get_current_exec_task() % 5) * 9 + 34,get_current_exec_task() / 5 + 5, GREEN, tmp); |
#endif |
if (l->act_number > act+1) generic_set_next_activation(&l->act[act+1]); |
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles; |
for (i=0;i<exec_cycles;i++) calibration_func(); |
generic_task_endcycle(); |
return NULL; |
} |
void * periodic_task(void *arg) |
{ |
long long i,exec_cycles = 0; |
int act = 0; |
struct loader_task *l = (struct loader_task *)(arg); |
char tmp[20]; |
while(1) { |
#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 |
act++; |
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[act])) * CALIBRATION_DELTA / cal_cycles; |
for (i=0;i<exec_cycles;i++) calibration_func(); |
generic_task_endcycle(); |
act++; |
} |
return NULL; |
} |
void * back_task(void *arg) |
{ |
long long i,exec_cycles = 0; |
int act = 0; |
struct loader_task *l = (struct loader_task *)(arg); |
char tmp[20]; |
while(1) { |
#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 |
exec_cycles = (long long)(TIMESPEC2USEC(&l->exec[0])) * CALIBRATION_DELTA / cal_cycles; |
for (i=0;i<exec_cycles;i++) calibration_func(); |
act++; |
} |
return NULL; |
} |
/* Task create */ |
/* this function create the task struct in memory */ |
void loader_task_create() |
{ |
47,20 → 97,31 |
int total_group = 0; |
total_task = sizeof(loader_task_list)/sizeof(struct loader_task); |
cprintf("Created 1 %d loader tasks\n",total_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)); |
void *func=NULL; |
switch(current->task_type) { |
case PAR_TASK_OS: |
func=oneshot_task; |
break; |
case PAR_TASK_BT: |
func=back_task; |
break; |
case PAR_TASK_CT: |
func=periodic_task; |
break; |
} |
err = generic_create_thread(current->server,&j,NULL,func,(void *)current,generic_get_task_model(current)); |
if (err) { |
cprintf("Error fsf task creating\n"); |
sys_end(); |
78,7 → 139,7 |
} |
int main() |
int start_environment() |
{ |
struct timespec total = {20,0}; |
93,6 → 154,8 |
generic_set_simulation_time(&total); |
generic_start_simulation(); |
return 0; |
} |
/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" 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 |