Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 1493 → Rev 1492

/demos/trunk/newtrace/instr/instr.c
23,75 → 23,158
*/
 
#include <kernel/kern.h>
#include <time.h>
#include <tracer.h>
 
#define PWCET_Automatic_Ipoint(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0);
#define IPOINT(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0);
 
extern int instrumented_function();
int num_aster = 0;
#define ASTER_LIM 67
#define ASTER_MAX 90
 
TASK ext_call(void)
TASK asteroide(void)
{
int i = 1;
int y = 0;
 
while(1) {
IPOINT(1000);
 
instrumented_function();
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;
 
}
 
#define TASKMAX 4
#define TASKDELAY 1000000
#define TASKDELAY_DELTA 100000
DWORD taskCreated = 0;
 
int exec_code() {
TASK aster(void)
{
PID p;
 
int num;
struct timespec t;
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;
PID p;
struct timespec t;
 
cprintf("Start\n");
 
clear();
 
cprintf("Start\n");
 
hard_task_default_model(m);
hard_task_def_mit(m,200000 + rand() % 100000);
hard_task_def_wcet(m,40000);
hard_task_def_mit(m,10000);
hard_task_def_wcet(m,2000);
hard_task_def_group(m,2);
 
num = 0;
p1 = task_create("Aster",aster,&m,NULL);
if (p1 == -1) {
sys_shutdown_message("Aster.C(main): Could not create task <aster> ...");
sys_end();
}
 
while(num < TASKMAX) {
 
p = task_create("Instr",ext_call,&m,NULL);
if (p == -1) {
sys_shutdown_message("Could not create task <instr> ...");
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();
}
 
num++;
task_activate(p);
group_activate(2);
 
usleep(TASKDELAY + rand() % TASKDELAY_DELTA);
 
}
 
do {
sys_gettime(&t);
} while (t.tv_sec < 12);
} while (t.tv_sec < 10);
 
cprintf("End\n");
cprintf("Done\n");
 
return 0;
 
}
 
int main(int argc, char **argv)
116,7 → 199,7
 
TRACER_LOGEVENT(FTrace_EVT_trace_start,0,0);
 
exec_code();
instrumented_routine();
 
TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0);
 
128,12 → 211,13
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.1.10", "192.168.1.1");
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);