Rev 1490 |
Rev 1493 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
* 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>
#define IPOINT(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0);
int num_aster
= 0;
#define ASTER_LIM 67
#define ASTER_MAX 90
TASK asteroide
(void)
{
int i
= 1;
int y
= 0;
IPOINT
(1000);
y
= rand() % 20 + 1;
while (i
< ASTER_LIM
) {
IPOINT
(1001);
puts_xy
(i
,y
,WHITE
,"*");
IPOINT
(1002);
task_testcancel
();
task_endcycle
();
puts_xy
(i
,y
,WHITE
," ");
i
++;
}
IPOINT
(1003);
num_aster
--;
IPOINT
(1004);
return 0;
}
DWORD taskCreated
= 0;
TASK aster
(void)
{
PID p
;
HARD_TASK_MODEL m
;
int r
;
IPOINT
(2000);
hard_task_default_model
(m
);
hard_task_def_wcet
(m
,500);
hard_task_def_group
(m
,3);
while (1) {
IPOINT
(2001);
if (num_aster
< ASTER_MAX
) {
IPOINT
(2002);
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
++;
}
IPOINT
(2003);
task_testcancel
();
task_endcycle
();
}
IPOINT
(2004);
}
TASK
clock()
{
int s
= 0, m
= 0;
IPOINT
(3000);
while(1) {
IPOINT
(3001);
printf_xy
(70,1,WHITE
,"%2d : %2d",m
,s
);
IPOINT
(3002);
task_endcycle
();
if (++s
> 59) {
IPOINT
(3003);
s
= 0;
m
++;
}
IPOINT
(3004);
printf_xy
(70,1,WHITE
,"%2d : %2d",m
,s
);
IPOINT
(3005);
task_testcancel
();
task_endcycle
();
}
IPOINT
(3006);
}
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
,2);
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
(2);
do {
sys_gettime
(&t
);
} while (t.
tv_sec < 10);
cprintf
("Done\n");
}
int main
(int argc
, char **argv
)
{
int a
,b
,c
;
struct timespec t
,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
);
FTrace_actual_chunk_select
(a
);
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);
group_kill
(2);
group_kill
(3);
do {
sys_gettime
(&t
);
} while (t.
tv_sec < 12);
FTrace_OSD_init_udp
(1, "192.168.82.43", "192.168.82.20");
FTrace_send_chunk
(a
, 0, FTRACE_CHUNK_FLAG_FREE
| FTRACE_CHUNK_FLAG_CYC
);
return 0;
}