Subversion Repositories shark

Rev

Rev 1085 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/**
20
 ------------
21
 CVS :        $Id: jetctrl.c,v 1.1.1.1 2002-09-02 09:37:44 pj Exp $
22
 
23
 File:        $File$
24
 Revision:    $Revision: 1.1.1.1 $
25
 Last update: $Date: 2002-09-02 09:37:44 $
26
 ------------
27
**/
28
 
29
/*
30
 * Copyright (C) 2000 Paolo Gai
31
 *
32
 * This program is free software; you can redistribute it and/or modify
33
 * it under the terms of the GNU General Public License as published by
34
 * the Free Software Foundation; either version 2 of the License, or
35
 * (at your option) any later version.
36
 *
37
 * This program is distributed in the hope that it will be useful,
38
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40
 * GNU General Public License for more details.
41
 *
42
 * You should have received a copy of the GNU General Public License
43
 * along with this program; if not, write to the Free Software
44
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
45
 *
46
 */
47
 
48
/*
49
 * this file is directly derived from the demos/jumpball/jetctrl.c .
50
 * I just added this controls to check when the system will become overloaded
51
 */
52
 
53
#define WCET_JETDUMMY      200
54
#define PERIOD_JETDUMMY 100000
55
#define DUMMY_PID    1
56
 
57
#define JET_DUMMY_WIDTH    (CMD_WIDTH-370)
58
#define JET_DUMMY_HEIGHT   (CMD_HEIGHT-40)
59
 
60
/* the point (x, y) is the top left corner */
61
#define JET_DUMMY_X        (TRACK_X1+360)
62
#define JET_DUMMY_Y        (TRACK_Y2+32)
63
 
64
// from jetdummy in the auto demo
65
#define SCREEN_WIDTH  800
66
#define SCREEN_HEIGHT 600
67
/* Track dimensions */
68
#define TRACK_WIDTH  500
69
#define TRACK_HEIGHT 500
70
/* Track position */
71
#define TRACK_X1        0
72
#define TRACK_Y1        0
73
#define TRACK_X2        TRACK_X1+TRACK_WIDTH-1
74
#define TRACK_Y2        TRACK_Y1+TRACK_HEIGHT-1
75
#define CMD_WIDTH       TRACK_WIDTH
76
#define CMD_HEIGHT      (SCREEN_HEIGHT-TRACK_HEIGHT-3)
77
 
78
// JetControl
79
 
80
#include "kernel/func.h"
81
#include "drivers/glib.h"
82
 
83
/* useful colors... */
84
int white;
85
int black;
86
int red;
87
int lightgray;
88
 
89
TASK jetdummy_task(void *arg)
90
{
91
  TIME   now_dummy, last_dummy, diff_dummy, slice;
92
  struct timespec now, last, diff;
93
  int x = 0;
94
  int height;
95
 
96
  NULL_TIMESPEC(&last);
97
  last_dummy = 0;
98
  for (;;) {
99
    task_nopreempt();
100
    jet_getstat(DUMMY_PID, NULL, NULL, NULL, &now_dummy);
101
    sys_gettime(&now);
102
    task_preempt();
103
 
104
    SUBTIMESPEC(&now, &last, &diff);
105
    slice = diff.tv_sec * 1000000 + diff.tv_nsec/1000;
106
    diff_dummy = now_dummy - last_dummy;
107
 
108
    height = (int)(JET_DUMMY_HEIGHT*((float)diff_dummy)/((float)slice));
109
 
110
    TIMESPEC_ASSIGN(&last, &now);
111
    last_dummy = now_dummy;
112
 
113
    grx_line(JET_DUMMY_X+x,JET_DUMMY_Y,
114
             JET_DUMMY_X+x,JET_DUMMY_Y+height          ,black);
115
    grx_line(JET_DUMMY_X+x,JET_DUMMY_Y+height,
116
             JET_DUMMY_X+x,JET_DUMMY_Y+JET_DUMMY_HEIGHT,white);
117
    grx_line(JET_DUMMY_X+(x+1)%JET_DUMMY_WIDTH,JET_DUMMY_Y,
118
             JET_DUMMY_X+(x+1)%JET_DUMMY_WIDTH,JET_DUMMY_Y+JET_DUMMY_HEIGHT,255);
119
 
120
    x = (x+1)%JET_DUMMY_WIDTH;
121
 
122
    task_endcycle();
123
  }
124
}
125
 
126
void init_jetcontrol(void)
127
{
128
    SOFT_TASK_MODEL m4;
129
 
130
    PID p4;
131
 
132
    /* useful colors ... */
133
    white = rgb16(255,255,255);
134
    black = rgb16(0,0,0);
135
    red   = rgb16(255,0,0);
136
    lightgray = rgb16(128,128,128);
137
 
138
    /* scenario */
139
    grx_text("System load",
140
             JET_DUMMY_X+8, JET_DUMMY_Y-10, lightgray, black);
141
    grx_rect(JET_DUMMY_X-1,               JET_DUMMY_Y-1,
142
             JET_DUMMY_X+JET_DUMMY_WIDTH, JET_DUMMY_Y+JET_DUMMY_HEIGHT+1, lightgray);
143
 
144
    grx_text("100%", JET_DUMMY_X-40, JET_DUMMY_Y, lightgray, black);
145
    grx_text("  0%", JET_DUMMY_X-40, JET_DUMMY_Y+JET_DUMMY_HEIGHT-8, lightgray, black);
146
 
147
    grx_line(JET_DUMMY_X-1, JET_DUMMY_Y, JET_DUMMY_X-5, JET_DUMMY_Y, lightgray);
148
    grx_line(JET_DUMMY_X-1, JET_DUMMY_Y+JET_DUMMY_HEIGHT, JET_DUMMY_X-5, JET_DUMMY_Y+JET_DUMMY_HEIGHT, lightgray);
149
 
150
    /* jetdummy task */
151
    soft_task_default_model(m4);
152
    soft_task_def_period(m4, PERIOD_JETDUMMY);
153
    soft_task_def_met(m4, WCET_JETDUMMY);
154
    soft_task_def_usemath(m4);
155
    p4 = task_create("jdmy", jetdummy_task, &m4, NULL);
156
    if (p4 == -1) {
157
        grx_close();
158
        perror("Could not create task <jetdummy>");
159
        sys_end();
160
    }
161
    task_activate(p4);
162
}
163