Rev 1655 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
/*
*
*
*/
#include "config.h"
#include <kernel/func.h>
#include <kernel/model.h>
#include <kernel/const.h>
#include <drivers/glib.h>
#include <stdlib.h>
#include <assert.h>
#include "mutex.h"
#include "xread.h"
#define PERIOD 250000
#define WCET 1000
#ifdef FULLCOLOR
#define BARCOLOR rgb16(255,0,0)
#define BARBG rgb16(0,0,0)
#define TEXTCOLOR rgb16(255,255,255)
#define TEXTBG rgb16(0,0,0)
#else
#define BARCOLOR 128
#define BARBG 0
#define TEXTCOLOR 255
#define TEXTBG 0
#endif
//#define XC 700
//#define YC 400
#define LEN 100
#define BORDER 8
extern void draw_frame
(int x
, int y
, int dx
, int dy
);
struct taskinfo
{
int XC
,YC
;
struct xbuffer
*ptr
;
};
static TASK monitorbuffer
(void *arg
)
{
struct taskinfo
*p
=(struct taskinfo
*)arg
;
int XC
,YC
;
int oy
,y
;
struct xbuffer
*ptr
;
int sum
,old
;
ptr
=p
->ptr
;
XC
=p
->XC
;
YC
=p
->YC
;
oy
=YC
+LEN
-1;
for (;;) {
sum
=freespace
(ptr
);
#ifndef NOGRX
y
=YC
+LEN
*sum
/BUFFERMAXSIZE
-1;
if (y
!=oy
) {
grxlock
();
if (y
<oy
) grx_box
(XC
,y
,XC
+BORDER
-1,oy
,BARCOLOR
);
else grx_box
(XC
,oy
,XC
+BORDER
-1,y
,BARBG
);
grxunlock
();
oy
=y
;
}
#else
cprintf
("@%i@",sum
);
#endif
old
=sum
;
task_endcycle
();
}
return 0;
}
int gbuffer_init
(struct xbuffer
*ptr
, int group
, int XC
, int YC
)
{
struct taskinfo
*info
;
SOFT_TASK_MODEL model
;
PID pid
;
#ifdef ACTIVATE
info
=(struct taskinfo
*)malloc(sizeof(struct taskinfo
));
if (info
==NULL
) sys_abort
(912);
info
->XC
=XC
;
info
->YC
=YC
;
info
->ptr
=ptr
;
soft_task_default_model
(model
);
soft_task_def_met
(model
,WCET
);
soft_task_def_wcet
(model
,WCET
);
soft_task_def_period
(model
,PERIOD
);
soft_task_def_periodic
(model
);
soft_task_def_group
(model
,group
);
soft_task_def_arg
(model
,(void*)info
);
/*soft_task_def_group(model,group);*/
pid
=task_create
("bufferload",monitorbuffer
,&model
,NULL
);
if (pid
==-1) return -6;
#else
pid
=-1;
#endif
#ifndef NOGRX
draw_frame
(XC
,YC
,BORDER
,LEN
);
grxlock
();
grx_text
("Buffer",XC
-18,YC
+LEN
+BORDER
*2,TEXTCOLOR
,TEXTBG
);
grx_text
("100%",XC
+BORDER
*2+1,YC
-4,TEXTCOLOR
,TEXTBG
);
grx_text
(" 75%",XC
+BORDER
*2+1,YC
+LEN
/4-4,TEXTCOLOR
,TEXTBG
);
grx_text
(" 50%",XC
+BORDER
*2+1,YC
+LEN
/4*2-4,TEXTCOLOR
,TEXTBG
);
grx_text
(" 25%",XC
+BORDER
*2+1,YC
+LEN
/4*3-4,TEXTCOLOR
,TEXTBG
);
grx_text
(" 0%",XC
+BORDER
*2+1,YC
+LEN
-4,TEXTCOLOR
,TEXTBG
);
grxunlock
();
#endif
return pid
;
}