Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1671 → Rev 1672

/unsupported/trunk/loader/loadfile/loadxml.fsf2
0,0 → 1,59
<?xml version="1.0" encoding="UTF-8"?>
<fsf_framework xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../generators/java/fsf-schema.xsd">
 
<simulation>
<time>20s 0u</time>
</simulation>
<contract>
<cmin>0s 3000u</cmin>
<tmax>0s 10000u</tmax>
<cmax>0s 3000u</cmax>
<tmin>0s 10000u</tmin>
<workload>0</workload>
<localscheduler type="POSIX">
<task_section type="BackTask">
<number>1</number>
<act_section>
<start_time>3s 0u</start_time>
</act_section>
<exec_section>
<exec_time>3s 0u</exec_time>
</exec_section>
</task_section>
<task_section type="OneShot">
<number>2</number>
<dline>0s 0u</dline>
<wcet>0s 0u</wcet>
<act_section>
<start_time>3s 0u</start_time>
</act_section>
<exec_section>
<exec_time>3s 0u</exec_time>
</exec_section>
</task_section>
</localscheduler>
</contract>
<contract>
<cmin>0s 3000u</cmin>
<tmax>0s 10000u</tmax>
<cmax>0s 3000u</cmax>
<tmin>0s 10000u</tmin>
<workload>0</workload>
<localscheduler type="EDF">
<task_section type="CyclicalTask">
<number>1</number>
<dline>1s 0u</dline>
<wcet>0s 100000u</wcet>
<act_section>
<start_time>3s 0u</start_time>
<period_time>1s 0u</period_time>
</act_section>
<exec_section>
<exec_time>0s 10000u</exec_time>
<delta_time>0s 10000u</delta_time>
</exec_section>
</task_section>
</localscheduler>
</contract>
 
</fsf_framework>
/unsupported/trunk/loader/loadfile/loadm.fsf
0,0 → 1,72
# CONTRACT SECTION
#
# CONTRACT NUMBER:CMIN:TMAX:CMAX:TMIN:WORKLOAD:DEADLINE:LOCAL SCHEDULER
#
# YOU WILL HAVE A SERVER FOR EACH SPECIFIED CONTRACT,
# SO IN THE TASK SECTION YOU CAN SPECIFY THE "CONTRACT NUMBER"
# INSTEAD OF THE SERVER NUMBER, WHICH IS CALCULATED INSIDE THE
# LOADER
#
# ALL THE TIME PARAMETERS INSIDE THIS FILE ARE ALWAYS EXPRESSED AS
# "[SECONDS][MICROSECONDS]" TO AVOID FLOATING POINT CALCULATIONS
#
# WORKLOAD
# 0 BOUNDED
# 1 INDETERMINATED
#
# LOCAL SCHEDULER
# NONE - DEFAULT FOR THE FRAMEWORK
# POSIX
# EDF
# RM
#
# TASK SECTION
#
# TASK TYPE:CONTRACT NUMBER:LOCAL SCHEDULER:NUMBER OF TASK:DEADLINE:WCET:TASK ACT TYPE (PAR1,PAR2,...):
# :TASK EXEC TYPE (PAR1,PAR2,...):CRITICAL SESSION (PAR1,PAR2,PAR3,PAR4);
#
# TASK TYPE
# OS - ONE_SHOT
# CT - CYCLICAL_TASK
# BT - BACKGROUND_TASK
#
# TASK EXEC TYPE
# EXEC_CONST(TIME)
# - CONSTANT EXEC TIME
# EXEC_MEAN(MEAN, DELTA)
# - VARIABLE EXEC TIME WITH CONSTANT DISTRIBUTION
#
# TASK ACTIVATION TIME
# ACT_SINGLE(START_TIME)
# ACT_PERIODIC(START_TIME, PERIOD)
# ACT_MEAN(START_TIME, MEAN, DELTA)
#
# CRITICAL SESSION
# CRIT(RES NUMBER, BLOCKING_TIME)
# NO_CRIT
#
 
TOTAL_EXEC_TIME:[20][0];
# SIMULATION TOTAL TIME
 
CONTRACT SECTION
 
[0]:[0][6000]:[0][30000]:[0][6000]:[0][30000]:[0]:[0][0]:EDF;
[1]:[0][6000]:[0][60000]:[0][6000]:[0][60000]:[0]:[0][0]:EDF;
[2]:[0][12000]:[0][60000]:[0][12000]:[0][60000]:[0]:[0][0]:POSIX;
 
END
 
TASK SECTION
 
CT:[0]:EDF:[2]:[1][0]:[0][40000]:ACT_PERIODIC([1][0],[1][0]):
:EXEC_CONST([0][16000]):CRIT([0],[0][2000]);
 
CT:[1]:EDF:[2]:[1][0]:[0][40000]:ACT_PERIODIC([2][0],[1][0]):
:EXEC_MEAN([0][16000],[0][10000]):CRIT([0],[0][2000]);
 
BT:[2]:POSIX:[2]:[0][0]:[0][0]:ACT_SINGLE([3][0]):
:EXEC_CONST([0][10000]):CRIT([0],[0][2000]);
 
END
 
/unsupported/trunk/loader/loadfile/load.fsf
0,0 → 1,76
# CONTRACT SECTION
#
# CONTRACT NUMBER:CMIN:TMAX:CMAX:TMIN:WORKLOAD:DEADLINE:LOCAL SCHEDULER
#
# YOU WILL HAVE A SERVER FOR EACH SPECIFIED CONTRACT,
# SO IN THE TASK SECTION YOU CAN SPECIFY THE "CONTRACT NUMBER"
# INSTEAD OF THE SERVER NUMBER, WHICH IS CALCULATED INSIDE THE
# LOADER
#
# ALL THE TIME PARAMETERS INSIDE THIS FILE ARE ALWAYS EXPRESSED AS
# "[SECONDS][MICROSECONDS]" TO AVOID FLOATING POINT CALCULATIONS
#
# WORKLOAD
# 0 BOUNDED
# 1 INDETERMINATED
#
# LOCAL SCHEDULER
# POSIX
# EDF
# RM
# NONE DEFAULT FROM THE FRAMEWORK
#
# TASK SECTION
#
# TASK TYPE:CONTRACT NUMBER:LOCAL SCHEDULER:NUMBER OF TASK:DEADLINE:WCET:TASK ACT TYPE (PAR1,PAR2,...):
# :TASK EXEC TYPE (PAR1,PAR2,...):CRITICAL SESSION (PAR1,PAR2,PAR3,PAR4);
#
# TASK TYPE
# OS - ONE_SHOT
# CT - CYCLICAL_TASK
# BT - BACKGROUND_TASK
#
# TASK EXEC TYPE
# EXEC_CONST(TIME)
# - CONSTANT EXEC TIME
# EXEC_MEAN(MEAN, DELTA)
# - VARIABLE EXEC TIME WITH CONSTANT DISTRIBUTION
#
# TASK ACTIVATION TIME
# ACT_SINGLE(START_TIME)
# ACT_PERIODIC(START_TIME, PERIOD)
# ACT_MEAN(START_TIME, MEAN, DELTA)
#
# CRITICAL SESSION
# CRIT(RES NUMBER, BLOCKING_TIME)
# NO_CRIT
#
 
TOTAL_EXEC_TIME:[20][0];
# SIMULATION TOTAL TIME
 
CONTRACT SECTION
 
[0]:[0][3000]:[0][10000]:[0][3000]:[0][10000]:[0]:[0][9000]:POSIX;
[1]:[0][6000]:[0][30000]:[0][6000]:[0][30000]:[0]:[0][0]:POSIX;
[2]:[0][3000]:[0][30000]:[0][3000]:[0][30000]:[0]:[0][0]:POSIX;
[3]:[0][3000]:[0][20000]:[0][3000]:[0][20000]:[0]:[0][0]:POSIX;
 
END
 
TASK SECTION
 
BT:[0]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([1][0]):
:EXEC_CONST([0][25000]):NO_CRIT;
 
BT:[1]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([2][0]):
:EXEC_CONST([0][16000]):NO_CRIT;
 
OS:[2]:POSIX:[1]:[0][0]:[0][0]:ACT_SINGLE([3][0]):
:EXEC_CONST([1][0]):NO_CRIT;
 
BT:[3]:POSIX:[5]:[0][0]:[0][0]:ACT_SINGLE([4][0]):
:EXEC_CONST([0][10000]):NO_CRIT;
 
END
 
/unsupported/trunk/loader/loadfile/loadr.fsf
0,0 → 1,72
# CONTRACT SECTION
#
# CONTRACT NUMBER:CMIN:TMAX:CMAX:TMIN:WORKLOAD:DEADLINE:LOCAL SCHEDULER
#
# YOU WILL HAVE A SERVER FOR EACH SPECIFIED CONTRACT,
# SO IN THE TASK SECTION YOU CAN SPECIFY THE "CONTRACT NUMBER"
# INSTEAD OF THE SERVER NUMBER, WHICH IS CALCULATED INSIDE THE
# LOADER
#
# ALL THE TIME PARAMETERS INSIDE THIS FILE ARE ALWAYS EXPRESSED AS
# "[SECONDS][MICROSECONDS]" TO AVOID FLOATING POINT CALCULATIONS
#
# WORKLOAD
# 0 BOUNDED
# 1 INDETERMINATED
#
# LOCAL SCHEDULER
# NONE - DEFAULT FOR THE FRAMEWORK
# POSIX
# EDF
# RM
#
# TASK SECTION
#
# TASK TYPE:CONTRACT NUMBER:LOCAL SCHEDULER:NUMBER OF TASK:DEADLINE:WCET:TASK ACT TYPE (PAR1,PAR2,...):
# :TASK EXEC TYPE (PAR1,PAR2,...):CRITICAL SESSION (PAR1,PAR2,PAR3,PAR4);
#
# TASK TYPE
# OS - ONE_SHOT
# CT - CYCLICAL_TASK
# BT - BACKGROUND_TASK
#
# TASK EXEC TYPE
# EXEC_CONST(TIME)
# - CONSTANT EXEC TIME
# EXEC_MEAN(MEAN, DELTA)
# - VARIABLE EXEC TIME WITH CONSTANT DISTRIBUTION
#
# TASK ACTIVATION TIME
# ACT_SINGLE(START_TIME)
# ACT_PERIODIC(START_TIME, PERIOD)
# ACT_MEAN(START_TIME, MEAN, DELTA)
#
# CRITICAL SESSION
# CRIT(RES NUMBER, BLOCKING_TIME)
# NO_CRIT
#
 
TOTAL_EXEC_TIME:[20][0];
# SIMULATION TOTAL TIME
 
CONTRACT SECTION
 
[0]:[0][9000]:[0][30000]:[0][9000]:[0][30000]:[0]:[0][0]:EDF;
[1]:[0][9000]:[0][30000]:[0][9000]:[0][30000]:[0]:[0][0]:EDF;
[2]:[0][6000]:[0][60000]:[0][6000]:[0][60000]:[0]:[0][0]:POSIX;
 
END
 
TASK SECTION
 
CT:[0]:EDF:[2]:[0][100000]:[0][40000]:ACT_PERIODIC([0][0],[0][100000]):
:EXEC_MEAN([0][8000]:[0][14000]):NO_CRIT;
 
CT:[1]:EDF:[2]:[0][100000]:[0][40000]:ACT_PERIODIC([0][0],[0][100000]):
:EXEC_MEAN([0][8000]:[0][14000]):NO_CRIT;
 
BT:[2]:POSIX:[2]:[0][0]:[0][0]:ACT_SINGLE([0][0]):
:EXEC_CONST([0][10000]):NO_CRIT;
 
END
 
/unsupported/trunk/loader/shark/shark.mak
0,0 → 1,13
ifndef BASE
BASE=../../..
endif
 
include $(BASE)/config/config.mk
 
PROGS = TEST
 
include $(BASE)/config/example.mk
 
TEST:
make -f $(SUBMAKE) APP="nload" BASE=../../.. INIT= OTHEROBJS="event.o initfile.o shark.o fsfinit.o" OTHERINCL="-I." SHARKOPT="__LINUXC26__ __PCI__ __NET__ __FIRST__"
cp nload TEST
/unsupported/trunk/loader/shark/func.h
0,0 → 1,112
#ifndef __FUNC_H__
#define __FUNC_H__
 
#include "kernel/kern.h"
#include "fsf_basic_types.h"
#include "fsf_core.h"
#include "fsf_server.h"
#include "shark.h"
 
#define OS_SHARK
 
 
#define get_current_exec_task() exec_shadow
/* Return the PID/pthread_t of calling task */
 
#define generic_get_server_from_contract get_server_from_contract
/* Return the server_id from the contract number used
* inside .fsf file to define contract parameters
*
* generic_get_server_from_contract(int contract_number) */
 
#define generic_calibrate_cycle calibrate_cycle
/* Set the calibration parameter "cal_cycle"
* only if it's initialized to 0. The calibration routine
* calculates cal_cycle from CALIBRATION_DELTA.
* This step can also be performed outside the demo.
* Inside calibrate.h you can set the calibration parameters
* for calibration step performed outside.
*
* cal_cycle is the number of cycles that are needed to
* make CALIBRATION_DELTA number of iteration.
*
* kern_cli();
* kern_gettime(&start);
* for (i=0;i<CALIBRATION_DELTA;i++)
* __asm__ __volatile__ ("xorl %%eax,%%eax\n\t"
* "cpuid\n\t"
* :::"eax","ebx","ecx","edx");
* kern_gettime(&end);
* kern_sti();
*
* SUBTIMESPEC(&end,&start,&diff);
* cal_cycles = TIMESPEC2USEC(&diff);
*
*/
 
#define generic_set_next_activation set_next_activation
/* Set the next activation time. It's like fsf_schedule_next_timed_job
* but it don't return nothing
*/
 
#define generic_set_simulation_time set_simulation_time
/* Set the end time of simulation */
 
#define generic_get_task_model get_task_model
/* Return a pointer to the struct that contains the
* local shceduler parameter */
 
#define generic_start_simulation start_simulation
/* Start the simulation */
 
#define generic_fsfinit() fsfinit()
/* Create the fsf_server */
 
#define generic_task_endcycle() task_endcycle()
/* The job is finished */
 
#define generic_end_simulation() exit(0)
/* Exit from simulation */
 
#define printf cprintf
/* Printf standard function */
 
/* Mutex */
extern __inline__ void generic_lock_mutex(int res) {
extern mutex_t mutex_table[MAX_MUTEX];
 
mutex_lock(&mutex_table[res]);
}
 
extern __inline__ void generic_unlock_mutex(int res) {
extern mutex_t mutex_table[MAX_MUTEX];
mutex_unlock(&mutex_table[res]);
}
 
/* TASK RUNTIME FUNCTIONS */
 
extern __inline__ void start_oneshot_task(void) {}
extern __inline__ void end_oneshot_task(void) {}
 
extern __inline__ void start_periodic_task(void) {}
extern __inline__ void start_job_periodic_task(void) {
task_testcancel();
}
extern __inline__ void end_job_periodic_task(void) {
task_testcancel();
}
extern __inline__ void end_periodic_task(void) {}
 
extern __inline__ void start_back_task(void) {}
extern __inline__ void start_job_back_task(void) {
task_testcancel();
}
extern __inline__ void end_job_back_task(void) {
task_testcancel();
}
extern __inline__ void end_back_task(void) {}
 
#endif
 
 
/unsupported/trunk/loader/shark/makefile.in
0,0 → 1,14
#
# Shark dependecies
#
 
os_specific_dep: out/shark.done out/makefile
 
 
out/shark.done:
cd out; cp -sf ../shark/*.c .
cd out; cp -sf ../shark/*.h .
touch out/shark.done
 
out/makefile: shark/shark.mak
sed -e "s/TEST/$(TEST)/" shark/shark.mak > out/makefile
/unsupported/trunk/loader/shark/fsfinit.c
0,0 → 1,62
#include "kernel/kern.h"
#include "fsf.h"
#include "fsf_server.h"
 
#include "func.h"
 
extern struct loader_contract loader_contract_list[];
extern int total_loader_contract;
 
void fsfinit()
{
 
struct loader_contract *c;
fsf_contract_parameters_t contract;
fsf_server_id_t server;
union sigval no_sigval = {0};
int i;
int err=0;
 
FSF_start_service_task();
 
for (i=0;i<total_loader_contract;i++) {
 
c = &loader_contract_list[i];
 
fsf_initialize_contract(&contract);
 
err=fsf_set_contract_basic_parameters(&contract,&c->cmin,&c->tmax,c->workload);
if (err) exit(err);
err=fsf_set_contract_reclamation_parameters(&contract,&c->cmax,&c->tmin,FSF_DEFAULT_GRANULARITY, NULL, 1,1);
if (err) exit(err);
 
if (TIMESPEC2USEC(&c->deadline) != 0)
err=fsf_set_contract_timing_requirements(&contract,false,&c->deadline,0,no_sigval,0,no_sigval);
else
err=fsf_set_contract_timing_requirements(&contract,true,NULL,0,no_sigval,0,no_sigval);
 
if (err) exit(err);
 
switch (c->local_scheduler) {
case PAR_EDF:
fsf_set_contract_scheduling_policy(&contract,FSF_EDF);
break;
case PAR_RM:
fsf_set_contract_scheduling_policy(&contract,FSF_FP);
break;
case PAR_POSIX:
fsf_set_contract_scheduling_policy(&contract,FSF_RR);
break;
 
}
 
err=fsf_negotiate_contract(&contract,&server);
if (err) exit(err);
c->server = server;
}
 
print_server_list();
 
}
/unsupported/trunk/loader/shark/initfile.c
0,0 → 1,182
/*
* Project: S.Ha.R.K.
*
* Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
*
* Authors :
* Mauro Marinoni <mauro.marinoni@unipv.it>
* Tullio Facchinetti <tullio.facchinetti@unipv.it>
* (see authors.txt for full list of hartik's authors)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://hartik.sssup.it
*/
 
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
 
#include <kernel/kern.h>
 
#include "edf/edf/edf.h"
#include "cbs/cbs/cbs.h"
#include "rr/rr/rr.h"
#include "dummy/dummy/dummy.h"
#include "intdrive/intdrive/intdrive.h"
 
#include "posix/posix/posix.h"
#include "grubstar.h"
#include "fsf_basic_types.h"
#include "fsf_core.h"
 
#include "pi/pi/pi.h"
#include "pc/pc/pc.h"
 
#include "pthread.h"
 
#include "sem/sem/sem.h"
#include "hartport/hartport/hartport.h"
#include "nop/nop/nop.h"
 
#include <drivers/shark_linuxc26.h>
#include <drivers/shark_pci26.h>
 
/*+ sysyem tick in us +*/
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
/*+ Interrupt Server +*/
#define INTDRIVE_Q 1000
#define INTDRIVE_U 0.1*MAX_BANDWIDTH
#define INTDRIVE_FLAG 0
 
void call_shutdown_task(void *arg);
int device_drivers_init();
int device_drivers_close();
void set_shutdown_task();
TASK shutdown_task_body(void *arg);
 
PID shutdown_task_PID = 1;
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
int grubstar_level;
int posix_level;
int pi_level;
int pc_level;
LEVEL EDF_level;
 
INTDRIVE_register_level(INTDRIVE_Q, INTDRIVE_Q, INTDRIVE_U, INTDRIVE_FLAG);
EDF_level = EDF_register_level(EDF_ENABLE_ALL);
posix_level=POSIX_register_level(RRTICK, 1, mb, 32);
grubstar_level = GRUBSTAR_register_level(FSF_MAX_N_SERVERS, 1);
 
FSF_register_module(posix_level,grubstar_level, (int)(MAX_BANDWIDTH * 0.8));
dummy_register_level();
//posix_level=POSIX_register_level(RRTICK, 1, mb, 32);
CBS_register_level(CBS_ENABLE_ALL,EDF_level);
SEM_register_module();
pi_level=PI_register_module();
pc_level=PC_register_module();
NOP_register_module();
PTHREAD_register_module(2, pi_level, pc_level);
 
return TICK;
}
 
int device_drivers_close() {
return 0;
}
 
int device_drivers_init() {
 
LINUXC26_register_module(TRUE);
PCI26_init();
 
return 0;
}
 
TASK shutdown_task_body(void *arg) {
 
device_drivers_close();
sys_shutdown_message("-- S.Ha.R.K. Closed --\n");
return NULL;
}
 
#define SHUTDOWN_TIMEOUT_SEC 3
 
void set_shutdown_task() {
 
NRT_TASK_MODEL nrt;
 
nrt_task_default_model(nrt);
nrt_task_def_system(nrt);
 
shutdown_task_PID = task_create("Shutdown Task", shutdown_task_body, &nrt, NULL);
if (shutdown_task_PID == NIL) {
sys_shutdown_message("Error: Cannot create shutdown task\n");
exit(0);
}
 
}
 
void call_shutdown_task(void *arg) {
 
struct timespec t;
 
sys_gettime(&t);
t.tv_sec += SHUTDOWN_TIMEOUT_SEC;
 
/* Emergency timeout to exit from RUNLEVEL_SHUTDOWN */
kern_event_post(&t,(void *)((void *)sys_abort_shutdown),(void *)0);
 
task_activate(shutdown_task_PID);
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
 
set_shutdown_task();
 
device_drivers_init();
 
sys_atrunlevel(call_shutdown_task, NULL, RUNLEVEL_SHUTDOWN);
 
__call_main__(mb);
 
return (void *)0;
}
 
int main() {
 
return start_environment();
 
}
 
/unsupported/trunk/loader/shark/shark.c
0,0 → 1,267
#include "func.h"
#include "calibrate.h"
#include <tracer.h>
 
#include "FTrace_udp.h"
#include "FTrace_chunk.h"
 
extern int cal_cycles;
extern struct timespec zero_time;
extern struct loader_task loader_task_list[];
extern struct loader_contract loader_contract_list[];
extern int total_loader_task;
extern int total_loader_contract;
extern unsigned int clk_per_msec;
 
mutex_t mutex_table[MAX_MUTEX];
int main_chunk;
 
/* Runtime Calibration */
int calibrate_cycle()
{
long long i;
struct timespec start,end,diff;
 
if (cal_cycles != 0) return 0;
 
kern_cli();
__asm__ __volatile__ ("xorl %%eax,%%eax\n\t"
"cpuid\n\t"
:::"eax","ebx","ecx","edx");
kern_gettime(&start);
for (i=0;i<CALIBRATION_DELTA;i++)
__asm__ __volatile__ ("xorl %%eax,%%eax\n\t"
"cpuid\n\t"
:::"eax","ebx","ecx","edx");
__asm__ __volatile__ ("xorl %%eax,%%eax\n\t"
"cpuid\n\t"
:::"eax","ebx","ecx","edx");
kern_gettime(&end);
kern_sti();
 
SUBTIMESPEC(&end,&start,&diff);
cal_cycles = TIMESPEC2USEC(&diff);
cprintf("Calibration usec/[%d cycles] = %d\n",CALIBRATION_DELTA,cal_cycles);
 
return 0;
 
}
 
int get_server_from_contract(int contract)
{
 
int i;
 
for(i=0;i<total_loader_contract;i++)
if (loader_contract_list[i].number == contract)
return loader_contract_list[i].server;
 
return -1;
 
}
 
void *get_task_model(struct loader_task *current) {
if (current->local_scheduler == PAR_POSIX) {
static NRT_TASK_MODEL nrt;
static fsf_sched_params_t pr;
pr.policy=FSF_RR;
pr.params=&nrt;
nrt_task_default_model(nrt);
nrt_task_def_save_arrivals(nrt);
nrt_task_def_ctrl_jet(nrt);
nrt_task_def_group(nrt,current->group);
nrt_task_def_usemath(nrt);
return &pr;
 
}
 
if (current->local_scheduler == PAR_EDF) {
static HARD_TASK_MODEL ht;
static fsf_sched_params_t pr;
 
pr.policy=FSF_EDF;
pr.params=&ht;
 
hard_task_default_model(ht);
hard_task_def_ctrl_jet(ht);
hard_task_def_mit(ht,TIMESPEC2USEC(&current->deadline));
hard_task_def_wcet(ht,TIMESPEC2USEC(&current->wcet));
hard_task_def_group(ht,current->group);
hard_task_def_aperiodic(ht);
hard_task_def_usemath(ht);
return &pr;
}
 
if (current->local_scheduler == PAR_NONE) {
static DUMMY_TASK_MODEL d;
static fsf_sched_params_t pr;
 
pr.policy=FSF_NONE;
pr.params=&d;
 
dummy_task_default_model(d);
dummy_task_def_group(d,current->group);
 
return &pr;
}
 
 
if (current->local_scheduler == PAR_RM) {
static HARD_TASK_MODEL ht;
static fsf_sched_params_t pr;
 
pr.policy=FSF_FP;
pr.params=&ht;
hard_task_default_model(ht);
hard_task_def_mit(ht,TIMESPEC2USEC(&current->deadline));
hard_task_def_wcet(ht,TIMESPEC2USEC(&current->wcet));
hard_task_def_ctrl_jet(ht);
hard_task_def_group(ht,current->group);
hard_task_def_usemath(ht);
 
return &pr;
}
 
return NULL;
}
 
TASK finish_task() {
#ifdef __NEW_TRACER__
//FTrace_OSD_init_udp(1,"192.168.82.43","192.168.82.205");
FTrace_OSD_init_udp(1, "192.168.82.205", "192.168.82.43");
 
FTrace_send_chunk(main_chunk, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
 
exit(0);
 
#else
exit(0);
 
#endif
 
return NULL;
}
 
void end_simulation() {
 
#ifdef __NEW_TRACER__
 
int i;
struct loader_task *l = loader_task_list;
 
NRT_TASK_MODEL nrt;
 
TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0);
FTrace_disable();
 
i = 0;
while (i < total_loader_task) {
group_kill(l->group);
 
i++;
l=&loader_task_list[i];
}
 
nrt_task_default_model(nrt);
 
task_activate(task_create("Finish",finish_task,&nrt,NULL));
 
#else
 
exit(0);
 
#endif
 
}
 
void set_simulation_time (struct timespec *total) {
struct timespec end_time;
ADDTIMESPEC(&zero_time,total,&end_time);
kern_event_post(&end_time,(void *)((void *)(end_simulation)),NULL);
 
}
 
/* Set the zero_time and post the first activation event */
void start_simulation() {
int i;
struct loader_task *l = loader_task_list;
struct timespec end_time;
PISTAR_mutexattr_t a;
 
PISTAR_mutexattr_default(a);
 
i = 0;
 
#ifdef __NEW_TRACER__
 
main_chunk = FTrace_chunk_create(10000000, 1000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
FTrace_actual_chunk_select(main_chunk);
FTrace_enable();
 
#endif
 
//TRACER_LOGEVENT(FTrace_EVT_trace_start,0,0);
 
TRACER_LOGEVENT(FTrace_EVT_trace_start,proc_table[exec_shadow].context,clk_per_msec);
 
for (i=0;i<10;i++)
if (proc_table[i].context != 0) TRACER_LOGEVENT(FTrace_EVT_id,
(unsigned short int)proc_table[i].context,i);
i = 0;
 
kern_gettime(&zero_time);
while (i < total_loader_task) {
if (l->muxstatus == 1) {
mutex_init(&mutex_table[l->resource],&a);
l->muxstatus = 2;
}
 
if (l->act_number > 0) {
ADDTIMESPEC(&zero_time, &l->act[0], &end_time);
l->act_current++;
kern_event_post(&end_time,(void *)((void *)(loader_task_activate)),l);
}
i++;
l=&loader_task_list[i];
 
}
 
}
 
/* Activate task and post the new activation event */
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,(void *)((void *)(loader_task_activate)),l);
 
}
 
}
/unsupported/trunk/loader/shark/shark.h
0,0 → 1,19
#ifndef __SHARK_H__
#define __SHARK_H__
 
#include "nload.h"
#include "lconst.h"
 
#define MAX_MUTEX 20
 
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 get_server_from_contract(int contract);
 
void fsfinit();
 
#endif
/unsupported/trunk/loader/marte/makefile.in
0,0 → 1,7
#
# MaRTE OS dependecies
#
 
os_specific_dep:
echo MaRTE dependencies here
 
/unsupported/trunk/loader/common/nload.h
0,0 → 1,46
/* Generic Struct for loader task */
#ifndef __NLOAD_H__
#define __NLOAD_H__
 
#include "func.h" //Constant definition for loader and linux parser
 
struct loader_task {
 
char name[20]; //Task name
int task_type; //Tast type (OS,CT,BT)
int contract; //Contract number
int local_scheduler; //Local scheduler for the task
int number; //How many copies of this task
int group; //Group number
struct timespec deadline; //Task deadline
struct timespec wcet; //Task wcet
int act_number; //Number of activations precalcolated
int act_current; //Actual activation number
 
int resource;
int muxstatus;
 
struct timespec *act; //Activation list
struct timespec *exec; //Execution time list
struct timespec *block; //Blocking time
 
};
 
struct loader_contract {
 
int number; //Contract number
struct timespec cmin;
struct timespec tmax;
struct timespec cmax;
struct timespec tmin;
int workload;
struct timespec deadline;
int local_scheduler;
int server; //Server number linked to this contract
 
};
 
#endif
 
/unsupported/trunk/loader/common/time.h
0,0 → 1,65
#ifndef __TIME_H__
#define __TIME_H__
 
#define TIMESPEC2NANOSEC(t) ((t)->tv_sec * 1000000000 + (t)->tv_nsec)
#define TIMESPEC2USEC(t) ((t)->tv_sec * 1000000 + (t)->tv_nsec / 1000)
#define NULL_TIMESPEC(t) ((t)->tv_sec = (t)->tv_nsec = 0)
#define ADDNANO2TIMESPEC(n, t) ((t)->tv_nsec += (n), \
(t)->tv_sec += (t)->tv_nsec / 1000000000, \
(t)->tv_nsec %= 1000000000)
 
#define SUBTIMESPEC(s1, s2, d) \
((d)->tv_nsec = ((s1)->tv_nsec >= (s2)->tv_nsec) ? \
(((d)->tv_sec = (s1)->tv_sec - (s2)->tv_sec), \
(s1)->tv_nsec - (s2)->tv_nsec) \
: \
(((d)->tv_sec = (s1)->tv_sec - (s2)->tv_sec - 1), \
(1000000000 + (s1)->tv_nsec - (s2)->tv_nsec)))
 
/*
* ...and these not!
*/
 
extern __inline__ void ADDTIMESPEC(const struct timespec *s1,
const struct timespec *s2,
struct timespec *d)
{
d->tv_sec = s1->tv_sec + s2->tv_sec;
d->tv_nsec = s1->tv_nsec + s2->tv_nsec;
 
if (d->tv_nsec < 0) {
d->tv_sec--;
d->tv_nsec += 1000000000;
} else if (d->tv_nsec >= 1000000000) {
d->tv_sec++;
d->tv_nsec -= 1000000000;
}
}
 
 
#define ADDUSEC2TIMESPEC(m, t) ((t)->tv_nsec += (m%1000000)*1000, \
(t)->tv_sec += ((t)->tv_nsec / 1000000000) + (m/1000000), \
(t)->tv_nsec %= 1000000000)
 
#define TIMESPEC_A_LT_B(a,b) \
( \
((a)->tv_sec < (b)->tv_sec) || \
((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec < (b)->tv_nsec) \
)
 
#define TIMESPEC_A_GT_B(a,b) \
( \
((a)->tv_sec > (b)->tv_sec) || \
((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec > (b)->tv_nsec) \
)
 
#define TIMESPEC_A_EQ_B(a,b) \
((a)->tv_sec == (b)->tv_sec && (a)->tv_nsec == (b)->tv_nsec)
 
#define TIMESPEC_A_NEQ_B(a,b) \
((a)->tv_sec != (b)->tv_sec || (a)->tv_nsec != (b)->tv_nsec)
 
#define TIMESPEC_ASSIGN(t1,t2) \
((t1)->tv_sec = (t2)->tv_sec, (t1)->tv_nsec = (t2)->tv_nsec)
 
#endif
/unsupported/trunk/loader/common/lconst.h
0,0 → 1,37
#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_CONTRACT_SECTION 14
#define PAR_TASK_SECTION 15
 
#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_NONE 33
 
#define PAR_FSF_SERVER 34
/unsupported/trunk/loader/common/calibrate.h
0,0 → 1,8
 
/* Nunber of calibration iterations */
#define CALIBRATION_DELTA 100000
 
/* Usec of exec time for CALIBRATING_DELTA iterations
Set to 0 if you calibrate during loader execution */
#define CALIBRATION_RESULT 0
 
/unsupported/trunk/loader/generators/java/Application.java
0,0 → 1,856
//package first_filter;
 
import java.io.*;
import java.net.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import org.jdom.*;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import java.util.regex.*;
import java.util.Random;
 
/**
* <p>Title: First XML filter</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Retis Lab</p>
* @author not attributable
* @version 1.0
*/
 
public class Application {
private int numElements = 0;
final String LOADFILE_DIR="../loadfile/";
final String EVENT_DEFINE="event.c";
final String ACT_LIST="event.c";
private int servernumber=0;
private timespec simulation_time=new timespec();
ArrayList local_scheduler=new ArrayList();
ArrayList Task_Section=new ArrayList();
private int task_group=0;
private int task_server=0;
private int current_scheduler=0;
 
 
 
//Construct the frame
public Application() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
}
 
public void process (String url) throws MalformedURLException {
try {
// Use SAXBuilder
SAXBuilder builder = new SAXBuilder("org.apache.xerces.parsers.SAXParser", true);
builder.setFeature("http://apache.org/xml/features/validation/schema", true);
 
 
Document doc = builder.build(url);
Element root = doc.getRootElement();
 
try {
// Funzione per il salvataggio del file XML
OutputStream fout = new FileOutputStream(EVENT_DEFINE);
OutputStream bout = new BufferedOutputStream(fout);
OutputStreamWriter out = new OutputStreamWriter(bout, "8859_1");
out.write("\n#include \"func.h\"\n");
 
processElement (root,out);
out.flush();
out.close();
} catch (UnsupportedEncodingException e) {
System.out.println("Non sono supportati i caratteri latini");
System.exit(1);
 
} catch (IOException e){
System.out.println("Salvatagio fallito");
System.exit(1);
}
 
 
 
System.out.println ("Total Number of Elements Processed: "
+numElements);
} catch (JDOMException e) {
System.out.println ("JDOM Exception: "+e.getMessage());
} catch (java.io.IOException e) {
System.out.println ("File Exception: "+e.getMessage());
 
}
}
 
// Recursive Function to Process Elements
// Prints the Element Name and keeps a running count
// out total number of elements.
private void processElement(Element element, OutputStreamWriter out) {
numElements++;
String elementName = element.getName();
 
System.out.println(elementName);
List servers = element.getChildren();
Iterator iterator = servers.iterator();
/* get simulation parameter */
Element SimulationInfo = (Element) iterator.next();
 
Pattern pattern = Pattern.compile("[us\\s]+");
try {
/*simulation time */
 
String[] stime = pattern.split(SimulationInfo.getChild("time").getText());
out.write("struct timespec total_time={" + stime[0] + "," + stime[1] +
"};\n\n");
simulation_time.tv_sec = Long.valueOf(stime[0].trim()).longValue();
simulation_time.tv_nsec = Long.valueOf(stime[1].trim()).longValue() /
1000;
//float f = Float.valueOf(s.trim()).floatValue();
/* server section start */
out.write("struct loader_contract loader_contract_list[] = {\n");
int total_server=0;
while (iterator.hasNext()) {
/* get server */
Element server = (Element) iterator.next();
process_server_section(server, out);
total_server++;
}
 
out.write("};\n\n");
 
out.write("int total_loader_contract="+total_server+";\n\n");
iterator = local_scheduler.iterator();
while (iterator.hasNext()) {
/* get server */
Element loc_sched = (Element) iterator.next();
process_scheduler_section(loc_sched, out);
task_server++;
}
 
iterator = Task_Section.iterator();
int total_task_section=0;
out.write("\nstruct loader_task loader_task_list[] = {\n");
while (iterator.hasNext()) {
/* get server */
task_class tsk_sec = (task_class) iterator.next();
out.write(" {\"" + tsk_sec.name + "\"," + tsk_sec.task_type + "," +
tsk_sec.contract +
"," + tsk_sec.localscheduler + "," + tsk_sec.number + ","
+ tsk_sec.group + ",{" + tsk_sec.deadline.tv_sec +
"," +
tsk_sec.deadline.tv_nsec + "}," + "{" +
tsk_sec.wcet.tv_sec + "," +
tsk_sec.wcet.tv_nsec + "}," + tsk_sec.act_number +
",0,act_" + tsk_sec.name +
",exec_" + tsk_sec.name + "},\n");
total_task_section++;
}
out.write("};\n\n");
out.write("int total_loader_task="+total_task_section+";\n\n");
 
 
}
catch (java.io.IOException e) {
System.out.println("File Exception: " + e.getMessage());
 
}
 
}
 
void process_scheduler_section(Element e, OutputStreamWriter out) {
Attribute t;
t=e.getAttribute("type");
 
List localpars = e.getChildren();
Iterator iterator = localpars.iterator();
while (iterator.hasNext()) {
/* get task section */
Element loc_task = (Element) iterator.next();
process_task_section(loc_task, out, t);
 
}
 
}
 
void process_task_section(Element e, OutputStreamWriter out, Attribute loc) {
Attribute t;
int act;
act=1;
int task_type=0;
int localscheduler=0;
timespec time = new timespec();
Pattern pattern = Pattern.compile("[us\\s]+");
String scheduler=loc.getValue();
if (scheduler.equals("POSIX")) {
localscheduler=30;
}
else if (scheduler.equals("EDF")) {
localscheduler=31;
}
else if (scheduler.equals("RM")) {
localscheduler=32;
}
 
/* get task section */
t=e.getAttribute("type");
 
if (t.getValue().equals("BackTask")) {
process_back_task(e, out);
task_type=23;
} else if (t.getValue().equals("OneShot")) {
process_oneshot_task(e, out);
task_type=21;
} else if (t.getValue().equals("CyclicalTask")) {
task_type=22;
act=process_cyclical_task(e, out);
}
 
task_class section=new task_class();
section.deadline=new timespec();
section.wcet=new timespec();
section.name="task"+task_group;
section.contract=task_server;
section.group=task_group;
section.act_number=act;
section.task_type=task_type;
section.localscheduler=localscheduler;
section.number=Integer.valueOf(e.getChild("number").getText()).intValue();
 
Element dl = e.getChild("dline");
if (dl != null) {
 
String[] dline=pattern.split(dl.getText());
time.tv_sec = Long.valueOf(dline[0]).longValue();
time.tv_nsec = Long.valueOf(dline[1]).longValue() * 1000;
section.deadline.tv_sec=time.tv_sec;
section.deadline.tv_nsec=time.tv_nsec;
 
}
 
 
Element wc = e.getChild("wcet");
if (wc != null) {
String[] wcet=pattern.split(e.getChild("wcet").getText());
time.tv_sec = Long.valueOf(wcet[0]).longValue();
time.tv_nsec = Long.valueOf(wcet[1]).longValue() * 1000;
section.wcet.tv_sec=time.tv_sec;
section.wcet.tv_nsec=time.tv_nsec;
 
}
 
Task_Section.add(section);
task_group++;
 
}
 
void process_back_task(Element e, OutputStreamWriter out) {
 
Pattern pattern = Pattern.compile("[us\\s]+");
 
Element act_section=e.getChild("act_section");
String[] start_time=pattern.split(act_section.getChild("start_time").getText());
Element exec_section=e.getChild("exec_section");
 
String[] exec_const=pattern.split(exec_section.getChild("exec_time").getText());
try {
out.write("struct timespec act_task"+task_group+"[]={{"+start_time[0]+","+start_time[1]+"},};\n\n");
out.write("struct timespec exec_task"+task_group+"[]={{"+exec_const[0]+","+exec_const[1]+"},};\n\n");
 
}
catch (java.io.IOException ex) {
System.out.println("File Exception: " + ex.getMessage());
 
}
}
void process_oneshot_task(Element e, OutputStreamWriter out) {
Pattern pattern = Pattern.compile("[us\\s]+");
Element act_section=e.getChild("act_section");
String[] start_time=pattern.split(act_section.getChild("start_time").getText());
 
Element exec_section=e.getChild("exec_section");
String[] exec_const=pattern.split(exec_section.getChild("exec_time").getText());
 
try {
out.write("struct timespec act_task"+task_group+"[]={{"+start_time[0]+","+start_time[1]+"},};\n\n");
out.write("struct timespec exec_task"+task_group+"[]={{"+exec_const[0]+","+exec_const[1]+"},};\n\n");
}
catch (java.io.IOException ex) {
System.out.println("File Exception: " + ex.getMessage());
}
}
 
int process_cyclical_task(Element e, OutputStreamWriter out) {
int activated=1;
Pattern pattern = Pattern.compile("[us\\s]+");
Element act_section=e.getChild("act_section");
String[] start_time=pattern.split(act_section.getChild("start_time").getText());
String[] period=pattern.split(act_section.getChild("period_time").getText());
Element deltatime=act_section.getChild("delta_time");
String[] delta_time;
 
long act_delta=0;
timespec delta_act_ts = new timespec();
 
if (deltatime != null) {
delta_time = pattern.split(deltatime.getText());
delta_act_ts.tv_sec = Long.valueOf(delta_time[0]).longValue();
delta_act_ts.tv_nsec = Long.valueOf(delta_time[1]).longValue() * 1000;
act_delta = delta_act_ts.TIMESPEC2USEC();
}
 
Element exec_section=e.getChild("exec_section");
String[] exec_const=pattern.split(exec_section.getChild("exec_time").getText());
Element execdelta=exec_section.getChild("delta_time");
String[] exec_delta;
 
long exec_delta_long = 0;
timespec exec_delta_ts = new timespec();
 
if (execdelta != null) {
exec_delta=pattern.split(execdelta.getText());
exec_delta_ts.tv_sec = Long.valueOf(exec_delta[0]).longValue();
exec_delta_ts.tv_nsec = Long.valueOf(exec_delta[1]).longValue() * 1000;
exec_delta_long = exec_delta_ts.TIMESPEC2USEC();
}
 
try {
out.write("struct timespec act_task"+task_group+"[]={{"+
start_time[0]+","+start_time[1]+"},\n");
 
timespec time = new timespec();
time.tv_sec = Long.valueOf(period[0]).longValue();
time.tv_nsec = Long.valueOf(period[1]).longValue() * 1000;
 
long usecperiod = time.TIMESPEC2USEC();
timespec nextact = new timespec();
 
time.tv_sec = Long.valueOf(start_time[0]).longValue();
time.tv_nsec = Long.valueOf(start_time[1]).longValue() * 1000;
Random rd = new Random();
 
while (simulation_time.TIMESPEC_A_GT_B(time)) {
 
nextact.tv_sec = Long.valueOf(period[0]).longValue();
nextact.tv_nsec = Long.valueOf(period[1]).longValue() * 1000;
 
if (act_delta != 0) {
nextact.ADDUSEC2TIMESPEC((rd.nextInt() & Integer.MAX_VALUE) % act_delta - act_delta/2);
}
 
time.ADDUSEC2TIMESPEC(usecperiod);
out.write(" {"+nextact.tv_sec+","+nextact.tv_nsec/1000+"},\n");
activated++;
}
out.write("};\n");
 
out.write("struct timespec exec_task"+task_group+"[]={\n");
 
timespec nextexec = new timespec();
 
for (int i=0; i<activated; i++) {
 
nextexec.tv_sec = Long.valueOf(exec_const[0]).longValue();
nextexec.tv_nsec = Long.valueOf(exec_const[1]).longValue() * 1000;
 
if (exec_delta_long != 0) {
nextexec.ADDUSEC2TIMESPEC((rd.nextInt() & Integer.MAX_VALUE) % exec_delta_long - exec_delta_long/2);
}
out.write(" {"+nextexec.tv_sec+","+nextexec.tv_nsec/1000+"},\n");
 
}
out.write("};\n");
}
catch (java.io.IOException ex) {
System.out.println("File Exception: " + ex.getMessage());
}
 
return activated;
}
 
void process_server_section(Element e, OutputStreamWriter out) {
 
 
List serverpars = e.getChildren();
Iterator iterator = serverpars.iterator();
Element serverpar = (Element) iterator.next();
String current_value;
current_value=serverpar.getText();
try {
out.write("{" + servernumber + ",{");
servernumber++;
 
Pattern pattern = Pattern.compile("[us\\s]+");
/* cmin */
String[] cmin = pattern.split(current_value);
out.write(cmin[0] + "," + Long.valueOf(cmin[1]).longValue()*1000+"},{");
 
/* tmax */
serverpar = (Element) iterator.next();
current_value=serverpar.getText();
String[] tmax = pattern.split(current_value);
out.write(tmax[0] + "," + Long.valueOf(tmax[1]).longValue()*1000+"},{");
 
/* cmax */
serverpar = (Element) iterator.next();
current_value=serverpar.getText();
String[] cmax = pattern.split(current_value);
out.write(cmax[0] + "," + Long.valueOf(cmax[1]).longValue()*1000+"},{");
 
/* tmin */
serverpar = (Element) iterator.next();
current_value=serverpar.getText();
String[] tmin = pattern.split(current_value);
out.write(tmin[0] + "," + Long.valueOf(tmin[1]).longValue()*1000+"},");
 
/*work load */
serverpar = (Element) iterator.next();
current_value=serverpar.getText();
out.write(current_value+",");
 
serverpar = (Element) iterator.next();
current_value=serverpar.getName();
Attribute loc_type=serverpar.getAttribute("type");
String scheduler=loc_type.getValue();
if (scheduler.equals("POSIX")) {
out.write("30");
}
else if (scheduler.equals("EDF")) {
out.write("31");
}
else if (scheduler.equals("RM")) {
out.write("32");
}
out.write(",-1},\n");
local_scheduler.add(servernumber-1,serverpar);
 
} catch (java.io.IOException ex) {
System.out.println ("File Exception: "+ex.getMessage());
}
 
/*
fprintf(file_event_header, " {%d,{%d,%d},{%d,%d},{%d,%d},{%d,%d},%d,%d,-1},\n",
(int)c->number,(int)c->cmin.tv_sec,(int)c->cmin.tv_nsec,
(int)c->tmax.tv_sec,(int)c->tmax.tv_nsec,
(int)c->cmax.tv_sec,(int)c->cmax.tv_nsec,
(int)c->tmin.tv_sec,(int)c->tmin.tv_nsec,
(int)c->workload,(int)c->local_scheduler);
 
*/
//processElement (kid);
}
 
 
 
public static void main(String[] args) throws Exception {
System.out.println("Parser Versione 1.0");
Application app = new Application();
if (args.length > 0)
app.process(args[0]);
}
 
/* Event Generator
*
* Giacomo Guidi
*/
 
 
 
 
 
/*
int write_basic_par_start(void)
{
 
FILE *file_event_header;
 
file_event_header = fopen(EVENT_DEFINE,"a+");
if (file_event_header == NULL) return 1;
 
fprintf(file_event_header, "struct loader_task loader_task_list[] = {\n");
 
fclose(file_event_header);
 
return 0;
 
}
 
 
int write_basic_par(struct loader_task *c)
{
 
FILE *file_event_header;
 
file_event_header = fopen(EVENT_DEFINE,"a+");
if (file_event_header == NULL) return 1;
 
fprintf(file_event_header, " {\"%s\",%d,%d,%d,%d,%d,{%d,%d},{%d,%d},%d,0,act_%s,exec_%s},\n",
c->name,(int)c->task_type,(int)c->server,(int)c->local_scheduler,(int)c->number,(int)c->group,
(int)c->deadline.tv_sec, (int)c->deadline.tv_nsec,
(int)c->wcet.tv_sec, (int)c->wcet.tv_nsec,
(int)c->act_number, c->name, c->name);
 
fclose(file_event_header);
 
return 0;
 
}
 
int write_contract(struct loader_contract *c)
{
 
FILE *file_event_header;
 
file_event_header = fopen(EVENT_DEFINE,"a+");
if (file_event_header == NULL) return 1;
 
fprintf(file_event_header, " {%d,{%d,%d},{%d,%d},{%d,%d},{%d,%d},%d,%d,-1},\n",
(int)c->number,(int)c->cmin.tv_sec,(int)c->cmin.tv_nsec,
(int)c->tmax.tv_sec,(int)c->tmax.tv_nsec,
(int)c->cmax.tv_sec,(int)c->cmax.tv_nsec,
(int)c->tmin.tv_sec,(int)c->tmin.tv_nsec,
(int)c->workload,(int)c->local_scheduler);
 
fclose(file_event_header);
 
return 0;
 
}
 
int close_loader_task(int total_task_number)
{
 
FILE *file_event_header;
 
file_event_header = fopen(EVENT_DEFINE,"a+");
if (file_event_header == NULL) return 1;
 
fprintf(file_event_header,"};\n\n");
 
fprintf(file_event_header,"int total_loader_task = %d;\n\n",total_task_number);
 
fclose(file_event_header);
 
return 0;
 
}
 
int close_loader_contract(int total_contract_number)
{
 
FILE *file_event_header;
 
file_event_header = fopen(EVENT_DEFINE,"a+");
if (file_event_header == NULL) return 1;
 
fprintf(file_event_header,"};\n\n");
 
fprintf(file_event_header,"int total_loader_contract = %d;\n\n",total_contract_number);
 
fclose(file_event_header);
 
return 0;
 
}
 
int write_simulation_time(struct timespec *total)
{
 
FILE *file_event_header;
 
file_event_header = fopen(EVENT_DEFINE,"a+");
if (file_event_header == NULL) return 1;
 
fprintf(file_event_header,"struct timespec total_time = {%d,%d};\n\n",(int)total->tv_sec,(int)total->tv_nsec);
 
fclose(file_event_header);
 
return 0;
 
 
}
 
int write_single_act(struct timespec *t, struct loader_task *c)
{
 
FILE *file_act_header;
 
file_act_header = fopen(ACT_LIST,"a+");
if (file_act_header == NULL) return 1;
 
if (TIMESPEC_A_GT_B(t,&c->act_par_1)) {
fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d}};\n\n",c->name,
(int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec);
c->act_number = 1;
} else {
fprintf(file_act_header,"struct timespec act_%s[] = {{0,0}};\n\n",c->name);
c->act_number = 0;
}
 
fclose(file_act_header);
 
return 0;
 
}
 
int write_periodic_act(struct timespec *t, struct loader_task *c)
{
 
FILE *file_act_header;
struct timespec tot_time;
int period;
 
file_act_header = fopen(ACT_LIST,"a+");
if (file_act_header == NULL) return 1;
 
fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name,
(int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec);
 
c->act_number = 1;
TIMESPEC_ASSIGN(&tot_time,&c->act_par_1);
period = TIMESPEC2USEC(&c->act_par_2);
while (TIMESPEC_A_GT_B(t, &tot_time)) {
c->act_number++;
ADDUSEC2TIMESPEC(period,&tot_time);
fprintf(file_act_header," {%d,%d},\n",
(int)c->act_par_2.tv_sec,(int)c->act_par_2.tv_nsec);
}
 
fprintf(file_act_header," };\n\n");
 
fclose(file_act_header);
 
return 0;
 
}
 
int write_mean_act(struct timespec *t,struct loader_task *c)
{
 
FILE *file_act_header;
struct timespec tot_time;
int next_act;
 
file_act_header = fopen(ACT_LIST,"a+");
if (file_act_header == NULL) return 1;
 
fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name,
(int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec);
 
c->act_number = 1;
TIMESPEC_ASSIGN(&tot_time,&c->act_par_1);
while (TIMESPEC_A_GT_B(t, &tot_time)) {
c->act_number++;
next_act = TIMESPEC2USEC(&c->act_par_2) + random() % TIMESPEC2USEC(&c->act_par_3) - TIMESPEC2USEC(&c->act_par_3) / 2;
ADDUSEC2TIMESPEC(next_act,&tot_time);
fprintf(file_act_header," {%d,%d},\n",
next_act / 1000000, next_act % 1000000 * 1000);
}
 
fprintf(file_act_header," };\n\n");
 
fclose(file_act_header);
 
return 0;
 
}
 
int write_exec_const(struct loader_task *c)
{
 
FILE *file_exec_header;
int i;
 
file_exec_header = fopen(ACT_LIST,"a+");
if (file_exec_header == NULL) return 1;
 
fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name,
(int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec);
 
for (i=0; i< c->act_number-1; i++)
fprintf(file_exec_header," {%d,%d},\n",
(int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec);
 
fprintf(file_exec_header," };\n\n");
 
fclose(file_exec_header);
 
return 0;
 
}
 
int write_exec_mean(struct loader_task *c)
{
 
FILE *file_exec_header;
int exec_time_usec;
int i;
 
file_exec_header = fopen(ACT_LIST,"a+");
if (file_exec_header == NULL) return 1;
 
exec_time_usec = TIMESPEC2USEC(&c->exec_par_1)
+ random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2;
fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name,
exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000);
 
for (i=0; i< c->act_number-1; i++) {
exec_time_usec = TIMESPEC2USEC(&c->exec_par_1)
+ random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2;
fprintf(file_exec_header," {%d,%d},\n",
exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000);
}
 
fprintf(file_exec_header," };\n\n");
 
fclose(file_exec_header);
 
return 0;
 
}
 
void *start;
void *end;
 
int main(int argc, char **argv) {
 
char loadfile[100];
struct timespec total_time;
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;
int total_contract_number;
 
printf("\nEvent Generator\n");
 
if (argc < 2) {
printf("Error: event_gen loadfile.fsf\n");
exit(1);
}
 
printf("Read loader file %s\n",argv[1]);
 
sprintf(loadfile,"%s%s",LOADFILE_DIR,argv[1]);
err = dos_preload(loadfile,100000,&start,&end);
 
if (err != 0) {
printf("Error: File not found\n");
exit(1);
}
 
printf("Parsing file\n");
 
line_reader(start, end, &total_time, &start_loader_task, &start_loader_contract);
 
srandom(time(NULL));
 
write_struct();
 
current_t = start_loader_task;
ldnum = 1;
 
while(current_t != NULL) {
 
sprintf(current_t->name,"ltask%d",ldnum);
current_t->group = ldnum;
ldnum++;
 
switch (current_t->act_type) {
case PAR_ACT_SINGLE:
err = write_single_act(&total_time,current_t);
if (err != 0) {
printf("Error writing activation header\n");
exit(1);
}
break;
case PAR_ACT_PERIODIC:
err = write_periodic_act(&total_time,current_t);
if (err != 0) {
printf("Error writing activation header\n");
exit(1);
}
break;
case PAR_ACT_MEAN:
err = write_mean_act(&total_time,current_t);
if (err != 0) {
printf("Error writing activation header\n");
exit(1);
}
break;
}
 
switch (current_t->exec_type) {
case PAR_EXEC_CONST:
err = write_exec_const(current_t);
if (err != 0) {
printf("Error writing exec header\n");
exit(1);
}
break;
case PAR_EXEC_MEAN:
err = write_exec_mean(current_t);
if (err != 0) {
printf("Error writing exec header\n");
exit(1);
}
break;
}
 
current_t = current_t->next;
 
}
 
write_basic_par_start();
 
total_task_number = 0;
current_t = start_loader_task;
while(current_t != NULL) {
 
write_basic_par(current_t);
 
current_t = current_t->next;
 
total_task_number++;
 
}
 
close_loader_task(total_task_number);
 
write_contract_start();
 
total_contract_number = 0;
current_c = start_loader_contract;
while(current_c != NULL) {
 
write_contract(current_c);
 
current_c = current_c->next;
 
total_contract_number++;
 
}
 
close_loader_contract(total_contract_number);
 
write_simulation_time(&total_time);
 
return 0;
 
}
 
*/
}
/unsupported/trunk/loader/generators/java/task_class.java
0,0 → 1,26
//package first_filter;
 
/**
* <p>Title: First XML filter</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Retis Lab</p>
* @author not attributable
* @version 1.0
*/
 
public class task_class {
String name;
int task_type;
int contract;
int localscheduler;
int number;
int group;
timespec deadline;
timespec wcet;
int act_number;
 
public task_class() {
}
 
}
/unsupported/trunk/loader/generators/java/timespec.java
0,0 → 1,37
//package first_filter;
 
/**
* <p>Title: First XML filter</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: Retis Lab</p>
* @author not attributable
* @version 1.0
*/
 
public class timespec {
long tv_sec;
long tv_nsec;
 
public timespec() {
tv_sec=0;
tv_nsec=0;
}
 
 
void ADDUSEC2TIMESPEC(long t1) {
tv_nsec+=(t1%1000000)*1000;
tv_sec+=(tv_nsec / 1000000000)+(t1/1000000);
tv_nsec%=1000000000;
}
long TIMESPEC2USEC() {
return (tv_sec*1000000+tv_nsec/1000);
}
boolean TIMESPEC_A_GT_B(timespec t1) {
 
return (tv_sec>t1.tv_sec ||
(tv_sec==t1.tv_sec && tv_nsec>t1.tv_nsec));
 
}
 
}
/unsupported/trunk/loader/generators/java/fsf-schema.xsd
0,0 → 1,75
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
 
<xs:element name="fsf_framework">
<xs:complexType>
<xs:sequence>
<xs:element ref="simulation"/>
<xs:element ref="contract" minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
</xs:complexType>
</xs:element>
 
<xs:element name="simulation">
<xs:complexType>
<xs:sequence>
<xs:element name="time" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
 
<xs:element name="contract">
<xs:complexType>
<xs:sequence>
<xs:element name="cmin" type="xs:string"/>
<xs:element name="tmax" type="xs:string" />
<xs:element name="cmax" type="xs:string" />
<xs:element name="tmin" type="xs:string" />
<xs:element name="workload" type="xs:string" />
<xs:element ref="localscheduler"/>
</xs:sequence>
</xs:complexType>
</xs:element>
 
<xs:element name="localscheduler">
<xs:complexType>
<xs:sequence>
<xs:element ref="task_section" minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use='required'/>
</xs:complexType>
</xs:element>
 
<xs:element name="task_section">
<xs:complexType>
<xs:sequence>
<xs:element name="number" type="xs:integer"/>
<xs:element name="dline" type="xs:string" minOccurs="0" />
<xs:element name="wcet" type="xs:string" minOccurs="0"/>
<xs:element ref="act_section"/>
<xs:element ref="exec_section"/>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use='required'/>
</xs:complexType>
</xs:element>
 
<xs:element name="act_section">
<xs:complexType>
<xs:sequence>
<xs:element name="start_time" type="xs:string"/>
<xs:element name="period_time" type="xs:string" minOccurs="0" />
<xs:element name="delta_time" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
 
<xs:element name="exec_section">
<xs:complexType>
<xs:sequence>
<xs:element name="exec_time" type="xs:string"/>
<xs:element name="delta_time" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
 
</xs:schema>
/unsupported/trunk/loader/generators/java/java_gen
0,0 → 1,10
#!/bin/bash
 
#if $CLASSPATH; then
#echo Please define the CLASSPATH environment variable!!!
#echo ...something like: export CLASSPATH=/usr/java/j2sdk1.4.2/jre/lib
#exit 1;
#fi
 
java -classpath ".:$CLASSPATH/jdom.jar:$CLASSPATH/xercesImpl.jar:$CLASSPATH/xml-apis.jar" Application $1
 
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: unsupported/trunk/loader/generators/java/makefile
===================================================================
--- unsupported/trunk/loader/generators/java/makefile (nonexistent)
+++ unsupported/trunk/loader/generators/java/makefile (revision 1672)
@@ -0,0 +1,17 @@
+ifdef CLASSPATH
+all:
+ javac Application.java timespec.java task_class.java -classpath "$(CLASSPATH)/jdom.jar"
+else
+all:
+ @echo ----------------------------------------------------------------
+ @echo Please define the CLASSPATH environment variable!!!
+ @echo ...something like: export CLASSPATH=/usr/java/j2sdk1.4.2/jre/lib
+ @echo ----------------------------------------------------------------
+ @exit 1
+endif
+
+
+clean:
+ rm -f *.class
+ rm -f event.c
+
Index: unsupported/trunk/loader/generators/lread.c
===================================================================
--- unsupported/trunk/loader/generators/lread.c (nonexistent)
+++ unsupported/trunk/loader/generators/lread.c (revision 1672)
@@ -0,0 +1,95 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include "lparser.h"
+#include "common/time.h"
+
+int dos_preload(char *file_name, long max_size, void **start_file, void **end_file)
+{
+ FILE *file;
+ void *buf;
+ long rd;
+
+
+ file = fopen(file_name,"r");
+ if (file == NULL) return -1;
+
+ buf = malloc(max_size);
+ *start_file = buf;
+
+ while(((rd = fread(buf, 1, 2048, file)) == 2048) &&
+ ((buf - *start_file + rd) < (max_size-2048))) {
+ buf += rd;
+ }
+
+ *end_file = buf + rd;
+
+ fclose(file);
+ return(0);
+
+}
+
+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,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, &current_c);
+ else
+ res = line_parser_contract(&pbuf, line_num, total, &current_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_task(&pbuf, line_num, &current_t);
+ else
+ res = line_parser_task(&pbuf, line_num, &current_t->next);
+
+ if (res == 2) {
+ total_loader_task++;
+ if (*start_loader_task == NULL)
+ *start_loader_task = current_t;
+ else
+ current_t = current_t->next;
+ }
+
+ if (res == 3) break;
+
+ }
+
+ 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);
+
+ return 0;
+
+}
Index: unsupported/trunk/loader/generators/lparser.c
===================================================================
--- unsupported/trunk/loader/generators/lparser.c (nonexistent)
+++ unsupported/trunk/loader/generators/lparser.c (revision 1672)
@@ -0,0 +1,486 @@
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include "lparser.h"
+#include "common/time.h"
+
+#define PARSER_DEBUG
+
+static int find_break(char **buf, int find_type, struct timespec *time, int *val)
+{
+
+ int i;
+ char str[20];
+
+ i = 0;
+ while (((char *)(*buf))[i] == ' ' || ((char *)(*buf))[i] == ':' ||
+ ((char *)(*buf))[i] == '\n' || ((char *)(*buf))[i] == '\r') i++;
+ *buf += i;
+
+ if (!strncmp(*buf,"END",3) && find_type == PAR_NOTHING) {
+ *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) {
+ while (((char *)(*buf))[i] != '\n' && ((char *)(*buf))[i] != '\r') i++;
+ *buf += i;
+ return PAR_FOUND;
+ }
+
+ switch (find_type) {
+
+ case PAR_NOTHING:
+ if (((char *)(*buf))[0] == ';' ||
+ ((char *)(*buf))[0] < 32) {
+ *buf += 1;
+ return PAR_FOUND;
+ }
+ break;
+
+ case PAR_TOTAL_EXEC_TIME:
+ if (!strncmp(*buf, "TOTAL_EXEC_TIME:",16)) {
+ *buf += 16;
+ return PAR_FOUND;
+ }
+ break;
+
+ case PAR_TIME:
+ if (((char *)(*buf))[0] != '[') return PAR_ERROR;
+ *buf += 1;
+ i = 0;
+ while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') {
+ str[i] = ((char *)(*buf))[i];
+ i++;
+ }
+ if (((char *)(*buf))[i] != ']') return PAR_ERROR;
+ str[i] = 0;
+ time->tv_sec = atoi(str);
+ i += 2;
+ *buf += i;
+ i = 0;
+ while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') {
+ str[i] = ((char *)(*buf))[i];
+ i++;
+ }
+ if (((char *)(*buf))[i] != ']') return PAR_ERROR;
+ str[i] = 0;
+ time->tv_nsec = atoi(str) * 1000;
+ i += 2;
+ *buf += i;
+ return PAR_FOUND;
+ break;
+
+ case PAR_TASK_TYPE:
+ if (!strncmp(*buf, "OS:",3)) {
+ *val = PAR_TASK_OS;
+ *buf += 3;
+ return PAR_FOUND;
+ }
+ if (!strncmp(*buf, "CT:",3)) {
+ *val = PAR_TASK_CT;
+ *buf += 3;
+ return PAR_FOUND;
+ }
+ if (!strncmp(*buf, "BT:",3)) {
+ *val = PAR_TASK_BT;
+ *buf += 3;
+ return PAR_FOUND;
+ }
+ break;
+
+ case PAR_TASK_NUMBER:
+ if (((char *)(*buf))[0] != '[') return PAR_ERROR;
+ *buf += 1;
+ i = 0;
+ while (((char *)(*buf))[i] >= '0' && ((char *)(*buf))[i] <= '9') {
+ str[i] = ((char *)(*buf))[i];
+ i++;
+ }
+ if (((char *)(*buf))[i] != ']') return PAR_ERROR;
+ str[i] = 0;
+ *val = atoi(str);
+ i += 2;
+ *buf += i;
+ return PAR_FOUND;
+ break;
+
+ case PAR_ACT_TYPE:
+ if (!strncmp(*buf,"ACT_SINGLE(",11)) {
+ *buf += 11;
+ *val = PAR_ACT_SINGLE;
+ return PAR_FOUND;
+ }
+ if (!strncmp(*buf,"ACT_PERIODIC(",13)) {
+ *buf += 13;
+ *val = PAR_ACT_PERIODIC;
+ return PAR_FOUND;
+ }
+ if (!strncmp(*buf,"ACT_MEAN(",9)) {
+ *buf += 9;
+ *val = PAR_ACT_MEAN;
+ return PAR_FOUND;
+ }
+ return PAR_ERROR;
+ break;
+
+ case PAR_LOCAL_SCHEDULER:
+ if (!strncmp(*buf,"POSIX",5)) {
+ *buf += 5;
+ *val = PAR_POSIX;
+ return PAR_FOUND;
+ }
+ if (!strncmp(*buf,"EDF",3)) {
+ *buf += 3;
+ *val = PAR_EDF;
+ return PAR_FOUND;
+ }
+ if (!strncmp(*buf,"RM",2)) {
+ *buf += 2;
+ *val = PAR_RM;
+ return PAR_FOUND;
+ }
+
+ if (!strncmp(*buf,"NONE",2)) {
+ *buf += 4;
+ *val = PAR_NONE;
+ return PAR_FOUND;
+ }
+
+ return PAR_ERROR;
+ break;
+
+ case PAR_EXEC_TYPE:
+ if (!strncmp(*buf,"EXEC_CONST(",11)) {
+ *buf += 11;
+ *val = PAR_EXEC_CONST;
+ return PAR_FOUND;
+ }
+ if (!strncmp(*buf,"EXEC_MEAN(",10)) {
+ *buf += 10;
+ *val = PAR_EXEC_MEAN;
+ return PAR_FOUND;
+ }
+ return PAR_ERROR;
+ break;
+
+ case PAR_CRIT_SESSION:
+ if (!strncmp(*buf,"NO_CRIT",7)) {
+ *buf += 7;
+ *val = PAR_NO_CRIT;
+ return PAR_FOUND;
+ }
+ if (!strncmp(*buf,"CRIT(",5)) {
+ *buf += 5;
+ *val = PAR_CRIT;
+ return PAR_FOUND;
+ }
+ return PAR_ERROR;
+ break;
+
+ }
+
+ return PAR_ERROR;
+
+}
+
+void par_error(int line_num)
+{
+
+ printf("\nParser error: line [%d]\n",line_num);
+ exit(1);
+
+}
+
+/* result:
+ * 0 -> nothing
+ * 1 -> total
+ * 2 -> new task-loader
+ * 3 -> end file
+ */
+int line_parser_task(char **pbuf, int line_num, struct loader_task **last)
+{
+ struct timespec time;
+ struct loader_task *ld = 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_TASK_TYPE, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("TASK TYPE = %d\n",val);
+ #endif
+
+ ld = malloc(sizeof(struct loader_task));
+ if (ld == NULL) par_error(line_num);
+
+ ld->next = NULL;
+ *last = ld;
+
+ ld->task_type = val;
+
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("TASK SERVER = %d\n",val);
+ #endif
+
+ ld->server = val;
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_LOCAL_SCHEDULER, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("TASK LOCAL SCHEDULER = %d\n",val);
+ #endif
+
+ ld->local_scheduler = val;
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("TASK NUMBER = %d\n",val);
+ #endif
+
+ ld->number = val;
+
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_TIME, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("DEADLINE: [%ld][%ld]\n",time.tv_sec,time.tv_nsec/1000);
+ #endif
+ TIMESPEC_ASSIGN(&ld->deadline,&time);
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_TIME, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("WCET: [%ld][%ld]\n",time.tv_sec,time.tv_nsec/1000);
+ #endif
+ TIMESPEC_ASSIGN(&ld->wcet,&time);
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_ACT_TYPE, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("ACTIVATION TYPE: %d (",val);
+ #endif
+
+ ld->act_type = val;
+
+ 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_1,&time);
+ } else par_error(line_num);
+
+ if (ld->act_type != PAR_ACT_SINGLE) {
+ 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_2,&time);
+ } 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
+
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_EXEC_TYPE, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("EXEC TYPE: %d (",val);
+ #endif
+ ld->exec_type = val;
+ 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_1,&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_2,&time);
+ } else par_error(line_num);
+ }
+
+ #ifdef PARSER_DEBUG
+ printf(")\n");
+ #endif
+
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_CRIT_SESSION, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("CRITITCAL SESSION: %d (",val);
+ #endif
+ ld->crit_type = val;
+ if (ld->crit_type == PAR_CRIT) {
+ res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("[%d]",val);
+ #endif
+ ld->resource = 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(&ld->crit_par,&time);
+ } else par_error(line_num);
+ }
+
+ #ifdef PARSER_DEBUG
+ printf(")\n");
+ #endif
+
+ } else par_error(line_num);
+
+ return 2;
+
+}
+
+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],",time.tv_sec,time.tv_nsec/1000);
+ #endif
+ TIMESPEC_ASSIGN(&lc->tmin,&time);
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_TASK_NUMBER, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf(",[%d]\n",val);
+ #endif
+
+ lc->workload = 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->deadline,&time);
+ } else par_error(line_num);
+
+ res = find_break(pbuf,PAR_LOCAL_SCHEDULER, &time, &val);
+ if (res == PAR_FOUND) {
+ #ifdef PARSER_DEBUG
+ printf("LOCAL SCHEDULER = %d\n",val);
+ #endif
+
+ lc->local_scheduler = val;
+ } else par_error(line_num);
+
+ return 2;
+
+}
Index: unsupported/trunk/loader/generators/event_gen.c
===================================================================
--- unsupported/trunk/loader/generators/event_gen.c (nonexistent)
+++ unsupported/trunk/loader/generators/event_gen.c (revision 1672)
@@ -0,0 +1,474 @@
+/* Event Generator
+ *
+ * Giacomo Guidi
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "lparser.h"
+#include "lread.h"
+#include "time.h"
+#include "common/time.h"
+
+#define LOADFILE_DIR "../loadfile/"
+
+#define EVENT_DEFINE "event.c"
+#define ACT_LIST "event.c"
+
+int write_struct(void)
+{
+
+ FILE *file_event_header;
+
+ file_event_header = fopen(EVENT_DEFINE,"w");
+ if (file_event_header == NULL) return 1;
+
+ fprintf(file_event_header, "\n#include \"func.h\"\n");
+
+ fclose(file_event_header);
+
+ return 0;
+
+}
+
+int write_basic_par_start(void)
+{
+
+ FILE *file_event_header;
+
+ file_event_header = fopen(EVENT_DEFINE,"a+");
+ if (file_event_header == NULL) return 1;
+
+ fprintf(file_event_header, "struct loader_task loader_task_list[] = {\n");
+
+ fclose(file_event_header);
+
+ return 0;
+
+}
+
+int write_contract_start(void)
+{
+
+ FILE *file_event_header;
+
+ file_event_header = fopen(EVENT_DEFINE,"a+");
+ if (file_event_header == NULL) return 1;
+
+ fprintf(file_event_header, "struct loader_contract loader_contract_list[] = {\n");
+
+ fclose(file_event_header);
+
+ return 0;
+
+}
+
+int write_basic_par(struct loader_task *c)
+{
+
+ FILE *file_event_header;
+ int muxpres;
+ char muxtemp[30];
+
+ file_event_header = fopen(EVENT_DEFINE,"a+");
+ if (file_event_header == NULL) return 1;
+
+ if (c->crit_type == PAR_CRIT) {
+ muxpres = 1;
+ sprintf(muxtemp,"block_%s",c->name);
+ } else {
+ muxpres = 0;
+ sprintf(muxtemp,"NULL");
+ }
+
+ fprintf(file_event_header, " {\"%s\",%d,%d,%d,%d,%d,{%d,%d},{%d,%d},%d,0,%d,%d,act_%s,exec_%s,%s},\n",
+ c->name,(int)c->task_type,(int)c->server,(int)c->local_scheduler,(int)c->number,(int)c->group,
+ (int)c->deadline.tv_sec, (int)c->deadline.tv_nsec,
+ (int)c->wcet.tv_sec, (int)c->wcet.tv_nsec,
+ (int)c->act_number, (int)c->resource, muxpres, c->name, c->name, muxtemp);
+
+ fclose(file_event_header);
+
+ return 0;
+
+}
+
+int write_contract(struct loader_contract *c)
+{
+
+ FILE *file_event_header;
+
+ file_event_header = fopen(EVENT_DEFINE,"a+");
+ if (file_event_header == NULL) return 1;
+
+ fprintf(file_event_header, " {%d,{%d,%d},{%d,%d},{%d,%d},{%d,%d},%d,{%d,%d},%d,-1},\n",
+ (int)c->number,(int)c->cmin.tv_sec,(int)c->cmin.tv_nsec,
+ (int)c->tmax.tv_sec,(int)c->tmax.tv_nsec,
+ (int)c->cmax.tv_sec,(int)c->cmax.tv_nsec,
+ (int)c->tmin.tv_sec,(int)c->tmin.tv_nsec,
+ (int)c->workload,
+ (int)c->deadline.tv_sec,(int)c->deadline.tv_nsec,
+ (int)c->local_scheduler);
+
+ fclose(file_event_header);
+
+ return 0;
+
+}
+
+int close_loader_task(int total_task_number)
+{
+
+ FILE *file_event_header;
+
+ file_event_header = fopen(EVENT_DEFINE,"a+");
+ if (file_event_header == NULL) return 1;
+
+ fprintf(file_event_header,"};\n\n");
+
+ fprintf(file_event_header,"int total_loader_task = %d;\n\n",total_task_number);
+
+ fclose(file_event_header);
+
+ return 0;
+
+}
+
+int close_loader_contract(int total_contract_number)
+{
+
+ FILE *file_event_header;
+
+ file_event_header = fopen(EVENT_DEFINE,"a+");
+ if (file_event_header == NULL) return 1;
+
+ fprintf(file_event_header,"};\n\n");
+
+ fprintf(file_event_header,"int total_loader_contract = %d;\n\n",total_contract_number);
+
+ fclose(file_event_header);
+
+ return 0;
+
+}
+
+int write_simulation_time(struct timespec *total)
+{
+
+ FILE *file_event_header;
+
+ file_event_header = fopen(EVENT_DEFINE,"a+");
+ if (file_event_header == NULL) return 1;
+
+ fprintf(file_event_header,"struct timespec total_time = {%d,%d};\n\n",(int)total->tv_sec,(int)total->tv_nsec);
+
+ fclose(file_event_header);
+
+ return 0;
+
+
+}
+
+int write_single_act(struct timespec *t, struct loader_task *c)
+{
+
+ FILE *file_act_header;
+
+ file_act_header = fopen(ACT_LIST,"a+");
+ if (file_act_header == NULL) return 1;
+
+ if (TIMESPEC_A_GT_B(t,&c->act_par_1)) {
+ fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d}};\n\n",c->name,
+ (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec);
+ c->act_number = 1;
+ } else {
+ fprintf(file_act_header,"struct timespec act_%s[] = {{0,0}};\n\n",c->name);
+ c->act_number = 0;
+ }
+
+ fclose(file_act_header);
+
+ return 0;
+
+}
+
+int write_periodic_act(struct timespec *t, struct loader_task *c)
+{
+
+ FILE *file_act_header;
+ struct timespec tot_time;
+ int period;
+
+ file_act_header = fopen(ACT_LIST,"a+");
+ if (file_act_header == NULL) return 1;
+
+ fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name,
+ (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec);
+
+ c->act_number = 1;
+ TIMESPEC_ASSIGN(&tot_time,&c->act_par_1);
+ period = TIMESPEC2USEC(&c->act_par_2);
+ while (TIMESPEC_A_GT_B(t, &tot_time)) {
+ c->act_number++;
+ ADDUSEC2TIMESPEC(period,&tot_time);
+ fprintf(file_act_header," {%d,%d},\n",
+ (int)c->act_par_2.tv_sec,(int)c->act_par_2.tv_nsec);
+ }
+
+ fprintf(file_act_header," };\n\n");
+
+ fclose(file_act_header);
+
+ return 0;
+
+}
+
+int write_mean_act(struct timespec *t,struct loader_task *c)
+{
+
+ FILE *file_act_header;
+ struct timespec tot_time;
+ int next_act;
+
+ file_act_header = fopen(ACT_LIST,"a+");
+ if (file_act_header == NULL) return 1;
+
+ fprintf(file_act_header,"struct timespec act_%s[] = {{%d,%d},\n",c->name,
+ (int)c->act_par_1.tv_sec,(int)c->act_par_1.tv_nsec);
+
+ c->act_number = 1;
+ TIMESPEC_ASSIGN(&tot_time,&c->act_par_1);
+ while (TIMESPEC_A_GT_B(t, &tot_time)) {
+ c->act_number++;
+ next_act = TIMESPEC2USEC(&c->act_par_2) + random() % TIMESPEC2USEC(&c->act_par_3) - TIMESPEC2USEC(&c->act_par_3) / 2;
+ ADDUSEC2TIMESPEC(next_act,&tot_time);
+ fprintf(file_act_header," {%d,%d},\n",
+ next_act / 1000000, next_act % 1000000 * 1000);
+ }
+
+ fprintf(file_act_header," };\n\n");
+
+ fclose(file_act_header);
+
+ return 0;
+
+}
+
+int write_block_const(struct loader_task *c)
+{
+
+ FILE *file_block_header;
+ int i;
+
+ file_block_header = fopen(ACT_LIST,"a+");
+ if (file_block_header == NULL) return 1;
+
+ fprintf(file_block_header,"struct timespec block_%s[] = {{%d,%d},\n",c->name,
+ (int)c->crit_par.tv_sec,(int)c->crit_par.tv_nsec);
+
+ for (i=0; i< c->act_number-1; i++)
+ fprintf(file_block_header," {%d,%d},\n",
+ (int)c->crit_par.tv_sec,(int)c->crit_par.tv_nsec);
+
+ fprintf(file_block_header," };\n\n");
+
+ fclose(file_block_header);
+
+ return 0;
+
+}
+
+int write_exec_const(struct loader_task *c)
+{
+
+ FILE *file_exec_header;
+ int i;
+
+ file_exec_header = fopen(ACT_LIST,"a+");
+ if (file_exec_header == NULL) return 1;
+
+ fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name,
+ (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec);
+
+ for (i=0; i< c->act_number-1; i++)
+ fprintf(file_exec_header," {%d,%d},\n",
+ (int)c->exec_par_1.tv_sec,(int)c->exec_par_1.tv_nsec);
+
+ fprintf(file_exec_header," };\n\n");
+
+ fclose(file_exec_header);
+
+ return 0;
+
+}
+
+int write_exec_mean(struct loader_task *c)
+{
+
+ FILE *file_exec_header;
+ int exec_time_usec;
+ int i;
+
+ file_exec_header = fopen(ACT_LIST,"a+");
+ if (file_exec_header == NULL) return 1;
+
+ exec_time_usec = TIMESPEC2USEC(&c->exec_par_1)
+ + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2;
+ fprintf(file_exec_header,"struct timespec exec_%s[] = {{%d,%d},\n",c->name,
+ exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000);
+
+ for (i=0; i< c->act_number-1; i++) {
+ exec_time_usec = TIMESPEC2USEC(&c->exec_par_1)
+ + random() % TIMESPEC2USEC(&c->exec_par_2) - TIMESPEC2USEC(&c->exec_par_2) / 2;
+ fprintf(file_exec_header," {%d,%d},\n",
+ exec_time_usec / 1000000, exec_time_usec % 1000000 * 1000);
+ }
+
+ fprintf(file_exec_header," };\n\n");
+
+ fclose(file_exec_header);
+
+ return 0;
+
+}
+
+void *start;
+void *end;
+
+int main(int argc, char **argv) {
+
+ char loadfile[100];
+ struct timespec total_time;
+ 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;
+ int total_contract_number;
+
+ printf("\nEvent Generator\n");
+
+ if (argc < 2) {
+ printf("Error: event_gen loadfile.fsf\n");
+ exit(1);
+ }
+
+ printf("Read loader file %s\n",argv[1]);
+
+ sprintf(loadfile,"%s%s",LOADFILE_DIR,argv[1]);
+ err = dos_preload(loadfile,100000,&start,&end);
+
+ if (err != 0) {
+ printf("Error: File not found\n");
+ exit(1);
+ }
+
+ printf("Parsing file\n");
+
+ line_reader(start, end, &total_time, &start_loader_task, &start_loader_contract);
+
+ srandom(time(NULL));
+
+ write_struct();
+
+ current_t = start_loader_task;
+ ldnum = 1;
+
+ while(current_t != NULL) {
+
+ sprintf(current_t->name,"ltask%d",ldnum);
+ current_t->group = ldnum;
+ ldnum++;
+
+ switch (current_t->act_type) {
+ case PAR_ACT_SINGLE:
+ err = write_single_act(&total_time,current_t);
+ if (err != 0) {
+ printf("Error writing activation header\n");
+ exit(1);
+ }
+ break;
+ case PAR_ACT_PERIODIC:
+ err = write_periodic_act(&total_time,current_t);
+ if (err != 0) {
+ printf("Error writing activation header\n");
+ exit(1);
+ }
+ break;
+ case PAR_ACT_MEAN:
+ err = write_mean_act(&total_time,current_t);
+ if (err != 0) {
+ printf("Error writing activation header\n");
+ exit(1);
+ }
+ break;
+ }
+
+ switch (current_t->exec_type) {
+ case PAR_EXEC_CONST:
+ err = write_exec_const(current_t);
+ if (err != 0) {
+ printf("Error writing exec header\n");
+ exit(1);
+ }
+ break;
+ case PAR_EXEC_MEAN:
+ err = write_exec_mean(current_t);
+ if (err != 0) {
+ printf("Error writing exec header\n");
+ exit(1);
+ }
+ break;
+ }
+
+ switch (current_t->crit_type) {
+ case PAR_CRIT:
+ err = write_block_const(current_t);
+ if (err != 0) {
+ printf("Error writing block header\n");
+ exit(1);
+ }
+ break;
+ }
+
+ current_t = current_t->next;
+
+ }
+
+ write_basic_par_start();
+
+ total_task_number = 0;
+ current_t = start_loader_task;
+ while(current_t != NULL) {
+
+ write_basic_par(current_t);
+
+ current_t = current_t->next;
+
+ total_task_number++;
+
+ }
+
+ close_loader_task(total_task_number);
+
+ write_contract_start();
+
+ total_contract_number = 0;
+ current_c = start_loader_contract;
+ while(current_c != NULL) {
+
+ write_contract(current_c);
+
+ current_c = current_c->next;
+
+ total_contract_number++;
+
+ }
+
+ close_loader_contract(total_contract_number);
+
+ write_simulation_time(&total_time);
+
+ return 0;
+
+}
Index: unsupported/trunk/loader/generators/makefile
===================================================================
--- unsupported/trunk/loader/generators/makefile (nonexistent)
+++ unsupported/trunk/loader/generators/makefile (revision 1672)
@@ -0,0 +1,9 @@
+event_gen:
+ gcc -o lparser.o -c -Wall lparser.c -I. -I..
+ gcc -o lread.o -c -Wall lread.c -I. -I..
+ gcc -o event_gen -Wall lparser.o lread.o -I. -I.. -lc event_gen.c
+
+clean:
+ rm -f *.o
+ rm -f event_gen
+
Index: unsupported/trunk/loader/generators/lread.h
===================================================================
--- unsupported/trunk/loader/generators/lread.h (nonexistent)
+++ unsupported/trunk/loader/generators/lread.h (revision 1672)
@@ -0,0 +1,11 @@
+#ifndef __LREAD_H__
+#define __LREAD_H__
+
+#include "lparser.h"
+
+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, struct loader_contract **start_loader_contract);
+
+#endif
Index: unsupported/trunk/loader/generators/lparser.h
===================================================================
--- unsupported/trunk/loader/generators/lparser.h (nonexistent)
+++ unsupported/trunk/loader/generators/lparser.h (revision 1672)
@@ -0,0 +1,58 @@
+#ifndef __LPARSER_H__
+#define __LPARSER_H__
+
+#include "common/lconst.h"
+
+struct loader_task {
+
+ char name[20];
+ int number;
+ int group;
+ int server;
+ int local_scheduler;
+ int task_type;
+
+ int act_type;
+ struct timespec act_par_1;
+ struct timespec act_par_2;
+ struct timespec act_par_3;
+ int exec_type;
+ struct timespec exec_par_1;
+ struct timespec exec_par_2;
+
+ struct timespec deadline;
+ struct timespec wcet;
+
+ int act_number;
+ struct timespec *act;
+ struct timespec *exec;
+
+ int crit_type;
+ int resource;
+ struct timespec crit_par;
+
+ struct loader_task *next;
+
+};
+
+struct loader_contract {
+
+ int number;
+ struct timespec cmin;
+ struct timespec tmax;
+ struct timespec cmax;
+ struct timespec tmin;
+ int workload;
+ struct timespec deadline;
+ int local_scheduler;
+
+ 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
+
Index: unsupported/trunk/loader/readme.txt
===================================================================
--- unsupported/trunk/loader/readme.txt (nonexistent)
+++ unsupported/trunk/loader/readme.txt (revision 1672)
@@ -0,0 +1,64 @@
+FIRST Framework Evaluation architecture
+---------------------------------------
+
+makefile usage:
+
+$ make OS=<osname> TEST=<demo> all
+
+where:
+
+<osname> is the name of the target operating system and it can be:
+
+- MARTE for MaRTE OS
+- SHARK for Shark
+
+<demo> is the name of the test case that have to be compiled. The
+specification of the test case is contained inside the loadfile
+directory.
+
+Valid extensions for the test case specification files are:
+.fsf - old script file
+.fsf2 - XML version
+(other extensions can be added easily)
+
+For example:
+
+make OS=SHARK TEST=load all
+
+these makefile will:
+- prepare the out directory with the common files
+- add the shark initialization files
+- parse a file loadfile/load.fsf (the file extension is guessed automatically
+ by the makefile) to produce source code inside out
+- compile the resulting shark application
+
+-------------------------------------------------------------------------
+
+XML Parser & Java setup
+
+To use the XML parser (file extension .fsf2) you need to properly setup
+your system, and you need toinstall the following libraries:
+
+- JDOM BETA 9 - http://www.jdom.org
+- XERCES (Parser SAX with XSD support) - http://xml.apache.org
+
+On my Linux system, after installing the Sun's j2re,
+I did the following commands (as root):
+
+# mkdir j
+# cd j
+# wget http://www.jdom.org/dist/binary/jdom-b9.tar.gz
+# tar xvzf jdom-b9.tar.gz
+# cp jdom-b9/build/jdom.jar /usr/java/j2re1.4.1_02/lib/
+# wget http://www.apache.org/dist/xml/xerces-j/Xerces-J-bin.2.6.0.tar.gz
+# tar xvzf Xerces-J-bin.2.6.0.tar.gz
+# cp ./xerces-2_6_0/xercesImpl.jar /usr/java/j2re1.4.1_02/lib/
+# cp ./xerces-2_6_0/xml-apis.jar /usr/java/j2re1.4.1_02/lib/
+
+then, as user, I did
+
+$ export CLASSPATH=/usr/java/j2re1.4.1_02/lib
+
+Enjoy,
+
+Michael, Giacomo, PJ
Index: unsupported/trunk/loader/makefile
===================================================================
--- unsupported/trunk/loader/makefile (nonexistent)
+++ unsupported/trunk/loader/makefile (revision 1672)
@@ -0,0 +1,88 @@
+#
+# help can be found in readme.txt
+#
+
+# -----------------------------------------------------
+#
+# OS dependent variables:
+
+# all the OS dependent variables and dependencies are under $(OS)/makefile.in
+
+# This makefile will execute the dependency os_specific_dep to "fill"
+# the out directory with OS-specific stuffs; Then, the makefile
+# generated in the out directory will be executed with $(TEST) as
+# parameter.
+
+ifndef $(BASE)
+BASE=../..
+endif
+
+include $(BASE)/config/config.mk
+
+ifeq ($(OS),MARTE)
+OSINCLUDE=marte/makefile.in
+endif
+
+ifeq ($(OS),SHARK)
+OSINCLUDE=shark/makefile.in
+endif
+
+# -----------------------------------------------------
+
+.PHONY: all clean help
+
+help:
+ifeq ($(CAT),cat)
+ cat readme.txt
+endif
+
+all: out out/common.done out/$(TEST).done os_specific_dep
+ make -C out $(TEST)
+
+clean:
+ make -C generators clean
+ make -C generators/java clean
+ rm -rf out
+
+out/common.done:
+ cd out; cp -sf ../common/*.c .
+ cd out; cp -sf ../common/*.h .
+ touch out/common.done
+
+# note: the out dependency is present only in the "all" dependency
+# (there is some strange case with the updating of the out date that I
+# do not know how to resolve...
+out:
+ mkdir out
+
+# -----------------------------------------------------
+#
+# Testcase generation
+
+# .FSF Format
+# -----------------------
+
+generators/event_gen:
+ make -C generators event_gen
+
+out/%.done: loadfile/%.fsf generators/event_gen
+ cd out; ../generators/event_gen ../loadfile/$(TEST).fsf
+ touch out/$*.done
+
+# .FSF2 Format
+# -----------------------
+
+generators/java/Applicazione.class:
+ make -C generators/java all
+
+out/%.done: loadfile/%.fsf2 generators/java/Applicazione.class
+ cd generators/java; ./java_gen ../../loadfile/$(TEST).fsf2; mv event.c ../../out/
+ touch out/$*.done
+
+# other file formats
+# -----------------------
+out/%.done: loadfile/%.otherformat
+ echo Other file formats that are not specified yet...
+ touch out/$*.done
+
+include $(OSINCLUDE)