Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1435 → Rev 1489

/demos/trunk/newtrace/instr/instr.c
0,0 → 1,210
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
/* The tracer instrumentation ideas come from the York PWCET analisys tool
*
* Real-Time System Group
* University of York
*
*/
 
#include <kernel/kern.h>
#include <tracer.h>
 
int num_aster = 0;
#define ASTER_LIM 67
#define ASTER_MAX 90
 
TASK asteroide(void)
{
int i = 1;
int y = 0;
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,1000,0);
 
y = rand() % 20 + 1;
 
while (i < ASTER_LIM) {
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,1001,0);
 
puts_xy(i,y,WHITE,"*");
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,1002,0);
task_endcycle();
 
puts_xy(i,y,WHITE," ");
i++;
}
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,1003,0);
num_aster--;
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,1004,0);
return 0;
 
}
 
DWORD taskCreated = 0;
 
TASK aster(void)
{
PID p;
 
HARD_TASK_MODEL m;
int r;
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,2000,0);
 
hard_task_default_model(m);
hard_task_def_wcet(m,500);
 
while (1) {
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,2001,0);
 
if (num_aster < ASTER_MAX) {
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,2002,0);
 
r = (rand() % 50) - 25;
 
hard_task_def_arg(m,(void *)((rand() % 7)+1));
hard_task_def_mit(m, (50+r)*1000);
p = task_create("aaa",asteroide,&m,NULL);
taskCreated++;
task_activate(p);
num_aster++;
}
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,2003,0);
task_endcycle();
 
}
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,2004,0);
 
}
 
TASK clock()
{
int s = 0, m = 0;
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3000,0);
 
while(1) {
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3001,0);
 
printf_xy(70,1,WHITE,"%2d : %2d",m,s);
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3002,0);
task_endcycle();
 
if (++s > 59) {
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3003,0);
s = 0;
m++;
 
}
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3004,0);
 
printf_xy(70,1,WHITE,"%2d : %2d",m,s);
 
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3005,0);
task_endcycle();
 
}
FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3006,0);
 
}
 
void instrumented_routine() {
 
PID p1,p2;
HARD_TASK_MODEL m;
struct timespec t;
 
cprintf("Start\n");
 
clear();
 
hard_task_default_model(m);
hard_task_def_mit(m,10000);
hard_task_def_wcet(m,2000);
hard_task_def_group(m,1);
 
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <aster> ...");
sys_end();
}
 
hard_task_def_mit(m,500000);
p2 = task_create("Clock",clock,&m,NULL);
if (p2 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <Clock> ...");
sys_end();
}
 
group_activate(1);
 
do {
sys_gettime(&t);
} while (t.tv_sec < 10);
 
cprintf("Done\n");
 
}
 
int main(int argc, char **argv)
{
 
int a,b,c;
struct timespec start,end,diff;
 
srand(sys_gettime(NULL));
 
a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN);
c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
 
FTrace_chunk_link(a,b);
FTrace_chunk_link(b,c);
 
kern_gettime(&start);
FTrace_enable();
 
TRACER_LOGEVENT(FTrace_EVT_trace_start,0,0);
 
instrumented_routine();
 
TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0);
 
FTrace_disable();
kern_gettime(&end);
 
SUBTIMESPEC(&end,&start,&diff);
 
printf_xy(1,21,WHITE,"Logged Time %d s %d us",(int)diff.tv_sec,(int)diff.tv_nsec/1000);
 
sys_end();
 
return 0;
 
}
 
/demos/trunk/newtrace/instr/initfile.c
0,0 → 1,61
/*
* Project: S.Ha.R.K.
*
* Coordinators:
* Giorgio Buttazzo <giorgio@sssup.it>
* Paolo Gai <pj@gandalf.sssup.it>
*
* Authors :
* Giacomo Guidi <giacomo@gandalf.sssup.it>
* (see the web pages for full authors list)
*
* ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
*
* http://www.sssup.it
* http://retis.sssup.it
* http://shark.sssup.it
*/
 
#include "kernel/kern.h"
#include "modules/edf.h"
#include "modules/cbs.h"
#include "modules/rr.h"
#include "modules/dummy.h"
 
#include "modules/sem.h"
#include "modules/hartport.h"
#include "modules/cabs.h"
 
/*+ sysyem tick in us +*/
#define TICK 0
 
/*+ RR tick in us +*/
#define RRTICK 10000
 
TIME __kernel_register_levels__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
EDF_register_level(EDF_ENABLE_ALL);
CBS_register_level(CBS_ENABLE_ALL, 0);
RR_register_level(RRTICK, RR_MAIN_YES, mb);
dummy_register_level();
 
SEM_register_module();
 
CABS_register_module();
 
return TICK;
}
 
TASK __init__(void *arg)
{
struct multiboot_info *mb = (struct multiboot_info *)arg;
 
HARTPORT_init();
 
__call_main__(mb);
 
return (void *)0;
}
 
/demos/trunk/newtrace/instr/makefile
0,0 → 1,16
#
#
#
 
ifndef BASE
BASE=../../..
endif
include $(BASE)/config/config.mk
 
PROGS = instr
 
include $(BASE)/config/example.mk
 
instr:
make -f $(SUBMAKE) BASE=$(BASE) APP=instr INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __NET__"