/demos/trunk/newtrace/instr/instr.c |
---|
23,158 → 23,75 |
*/ |
#include <kernel/kern.h> |
#include <time.h> |
#include <tracer.h> |
#define IPOINT(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0); |
#define PWCET_Automatic_Ipoint(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0); |
int num_aster = 0; |
#define ASTER_LIM 67 |
#define ASTER_MAX 90 |
extern int instrumented_function(); |
TASK asteroide(void) |
TASK ext_call(void) |
{ |
int i = 1; |
int y = 0; |
IPOINT(1000); |
while(1) { |
y = rand() % 20 + 1; |
while (i < ASTER_LIM) { |
IPOINT(1001); |
puts_xy(i,y,WHITE,"*"); |
IPOINT(1002); |
instrumented_function(); |
task_testcancel(); |
task_endcycle(); |
puts_xy(i,y,WHITE," "); |
i++; |
} |
IPOINT(1003); |
num_aster--; |
IPOINT(1004); |
return 0; |
} |
DWORD taskCreated = 0; |
#define TASKMAX 4 |
#define TASKDELAY 1000000 |
#define TASKDELAY_DELTA 100000 |
TASK aster(void) |
{ |
PID p; |
int exec_code() { |
int num; |
struct timespec t; |
HARD_TASK_MODEL m; |
int r; |
PID p; |
IPOINT(2000); |
clear(); |
cprintf("Start\n"); |
hard_task_default_model(m); |
hard_task_def_wcet(m,500); |
hard_task_def_group(m,3); |
hard_task_def_mit(m,200000 + rand() % 100000); |
hard_task_def_wcet(m,40000); |
hard_task_def_group(m,2); |
while (1) { |
IPOINT(2001); |
num = 0; |
if (num_aster < ASTER_MAX) { |
while(num < TASKMAX) { |
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++; |
p = task_create("Instr",ext_call,&m,NULL); |
if (p == -1) { |
sys_shutdown_message("Could not create task <instr> ..."); |
sys_end(); |
} |
IPOINT(2003); |
task_testcancel(); |
task_endcycle(); |
num++; |
task_activate(p); |
} |
usleep(TASKDELAY + rand() % TASKDELAY_DELTA); |
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); |
} while (t.tv_sec < 12); |
cprintf("Done\n"); |
cprintf("End\n"); |
return 0; |
} |
int main(int argc, char **argv) |
199,7 → 116,7 |
TRACER_LOGEVENT(FTrace_EVT_trace_start,0,0); |
instrumented_routine(); |
exec_code(); |
TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0); |
211,13 → 128,12 |
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_OSD_init_udp(1, "192.168.1.10", "192.168.1.1"); |
FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
/demos/trunk/newtrace/instr/bezier.c |
---|
0,0 → 1,110 |
#include <kernel/kern.h> |
#include <tracer.h> |
#define PWCET_Automatic_Ipoint(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0); |
/* here are the bezier curves defined |
format: |
{startpoint, endpoint, controlpoint1, controlpoint} |
. |
. |
. */ |
int curveno = 20; |
int data[20][4][2] = { |
{{123,321},{ 23,432},{345,120},{123, 98}}, |
{{567, 31},{ 23, 24},{ 35,421},{123,398}}, |
{{ 0, 21},{623,532},{145,323},{153, 68}}, |
{{253,321},{ 23,432},{745,525},{423,198}}, |
{{123,456},{ 23,482},{ 0,123},{123,128}}, |
{{322, 21},{223,232},{ 45,224},{123,98}}, |
{{423, 32},{123,332},{144,329},{123,98}}, |
{{276, 35},{ 23,492},{476,423},{123,98}}, |
{{783,121},{723,139},{ 78,528},{123,98}}, |
{{723,221},{623, 98},{734,683},{123,98}}, |
{{ 60,421},{523,132},{364,753},{123,98}}, |
{{100,521},{423,432},{633,623},{123,98}}, |
{{ 23,371},{323,599},{343,533},{123,98}}, |
{{123,123},{123, 0},{343,403},{123,98}}, |
{{253,321},{490, 32},{347,393},{123,98}}, |
{{ 68,321},{260,272},{674,283},{123,98}}, |
{{500,321},{245,373},{ 98,173},{123,98}}, |
{{423,321},{198,532},{306, 63},{123,98}}, |
{{197,321},{203,432},{307,443},{123,98}}, |
{{143,321},{293,132},{334,393},{123,98}} |
}; |
#define STEPWIDTH 0.01 /* draws 1/STEPWIDTH +1 points between SP and EP */ |
#define XSIZE 800 |
#define YSIZE 600 |
char screen[YSIZE][XSIZE]; |
int xco[4],yco[4]; |
int init() |
{ |
int y,x; |
/*initialize screen*/ |
for (x = 0;x < XSIZE;x++) { |
for (y = 0;y < YSIZE;y++) { |
screen[y][x] = 255; /*white*/ |
} |
} |
return 0; |
} |
void rand_init() |
{ |
int i,j,x,y; |
for (i=0;i<20;i++) |
for (j=0;j<4;j++) { |
x=rand()%800; |
y=rand()%600; |
data[i][j][0]=x; |
data[i][j][1]=y; |
} |
} |
int bezier() |
{ |
int i,y,x; |
float k; |
init(); |
for (i = 0;i < curveno;i++) { |
xco[3] = data[i][0][0]; |
yco[3] = data[i][0][1]; |
xco[2] = 3*(data[i][2][0] - data[i][0][0]); |
yco[2] = 3*(data[i][2][1] - data[i][0][1]); |
xco[1] = 3*(data[i][3][0] - data[i][2][0]) - xco[2]; |
yco[1] = 3*(data[i][3][1] - data[i][2][1]) - yco[2]; |
xco[0] = data[i][1][0] - data[i][0][0] - xco[2]- xco[1]; |
yco[0] = data[i][1][1] - data[i][0][1] - yco[2]- yco[1]; |
/*scan curve for t = 0 to t = 1 with STEPWIDTH*/ |
for (k = 0;k <=1;k+=STEPWIDTH) { /* PAN_FIXED_LOOP PAN_VARPATH */ |
x = (int)(((float)xco[0]*k*k*k)+((float)xco[1]*k*k)+((float)xco[2]*k)+(float)xco[3]); |
y = (int)(((float)yco[0]*k*k*k)+((float)yco[1]*k*k)+((float)yco[2]*k)+(float)yco[3]); |
if ((x < XSIZE)&&(x > 0)&&(y < YSIZE)&&(y > 0)) { |
/*write dot to screen*/ |
screen[y][x] = 0; /*black*/ |
} |
} |
} |
return 0; |
} |
int instrumented_function() { |
rand_init(); |
bezier(); |
return 0; |
} |
/demos/trunk/newtrace/instr/makefile |
---|
12,5 → 12,5 |
include $(BASE)/config/example.mk |
instr: |
make -f $(SUBMAKE) BASE=$(BASE) APP=instr INIT= OTHEROBJS="initfile.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __NET__" |
make -f $(SUBMAKE) BASE=$(BASE) APP=instr INIT= OTHEROBJS="initfile.o bezier.o" OTHERINCL= SHARKOPT="__LINUXC26__ __PCI__ __INPUT__ __NET__" |
/demos/trunk/newtrace/makefile |
---|
3,8 → 3,13 |
all: |
make -C udp |
make -C nosave |
make -C instr |
make -C utils util_linux |
clean: |
make -C udp clean |
make -C nosave clean |
make -C instr clean |
make -C utils clean |