Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 pj 1
/*
2
 * Project: HARTIK (HA-rd R-eal TI-me K-ernel)
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *               Gerardo Lamastra <gerardo@sssup.it>
6
 *
7
 * Authors     : Paolo Gai <pj@hartik.sssup.it>
8
 * (see authors.txt for full list of hartik's authors)
9
 *
10
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
11
 *
12
 * http://www.sssup.it
13
 * http://retis.sssup.it
14
 * http://hartik.sssup.it
15
 */
16
 
17
/**
18
 ------------
19
 CVS :        $Id: testb.c,v 1.1.1.1 2002-09-02 09:37:48 pj Exp $
20
 
21
 File:        $File$
22
 Revision:    $Revision: 1.1.1.1 $
23
 Last update: $Date: 2002-09-02 09:37:48 $
24
 ------------
25
 
26
 Test Number 11 (B):
27
 
28
 CBS test, similar to Test 10
29
 
30
 There are 4 CBS aperiodic tasks and 1 periodic task.
31
 after 5 secs, there is another activation of two of the four tasks.
32
 at sec. 10 the test stops.
33
 
34
**/
35
 
36
/*
37
 * Copyright (C) 2000 Paolo Gai
38
 *
39
 * This program is free software; you can redistribute it and/or modify
40
 * it under the terms of the GNU General Public License as published by
41
 * the Free Software Foundation; either version 2 of the License, or
42
 * (at your option) any later version.
43
 *
44
 * This program is distributed in the hope that it will be useful,
45
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47
 * GNU General Public License for more details.
48
 *
49
 * You should have received a copy of the GNU General Public License
50
 * along with this program; if not, write to the Free Software
51
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
52
 *
53
 */
54
 
55
#include "kernel/kern.h"
56
 
57
#if !defined(__TEST1__)
58
  THE TEST REQUIRE THE DEFINITION __TEST1__ IN CONFIG.C
59
#endif
60
 
61
struct timespec s_stime[10000];
62
struct timespec s_send[10000];
63
TIME s_curr[10000];
64
PID  s_PID[10000];
65
int useds=0;
66
int testactive=1;
67
 
68
 
69
TASK pippo()
70
{
71
  int i;
72
  struct timespec t;
73
  int last = 0;
74
 
75
  do {
76
    kern_cli();
77
    ll_gettime(TIME_EXACT, &t);
78
    kern_sti();
79
  } while (t.tv_nsec <= 30000000L);
80
}
81
 
82
TASK pippo2()
83
{
84
  int i;
85
  struct timespec t;
86
  int last = 0;
87
 
88
  do {
89
    kern_cli();
90
    ll_gettime(TIME_EXACT, &t);
91
    kern_sti();
92
 
93
  } while (t.tv_nsec <= 30000000L);
94
}
95
 
96
TASK asteroide(void)
97
{
98
    int i;
99
    int y = rand() % 7 + 15;
100
 
101
    int load1,j;
102
 
103
    char s[2];
104
 
105
    s[0] = '*'; s[1] = 0;
106
 
107
    /*for (;;)*/ {
108
      i = 1;
109
      while (i < 60) {
110
        load1 = 10000; //8000 + rand()%2000;
111
        for (j=0; j<load1; j++) {
112
          s[0] = '*' + rand() % 100;
113
          puts_xy(i,y,rand()%15+1,s);
114
        }
115
        task_endcycle();
116
 
117
        if (i==7)  testactive = 0;
118
 
119
        puts_xy(i,y,WHITE," ");
120
        i++;
121
      }
122
    }
123
    //num_aster--;
124
}
125
 
126
TASK aper(void *a)
127
{
128
    int i;
129
    int y;
130
 
131
    int load1,j;
132
 
133
    char s[2];
134
 
135
    y = (int) a;
136
 
137
    s[0] = '*'; s[1] = 0;
138
 
139
    /*for (;;)*/ {
140
      i = 1;
141
      while (i < 60) {
142
        load1 = 600000; //8000 + rand()%2000;
143
        for (j=0; j<load1; j++) {
144
          s[0] = '*' + rand() % 100;
145
          puts_xy(i,y,rand()%15+1,s);
146
        }
147
 
148
        task_endcycle();
149
 
150
        puts_xy(i,y,WHITE," ");
151
        i++;
152
      }
153
    }
154
    //num_aster--;
155
}
156
 
157
 
158
int main(int argc, char **argv)
159
{
160
  struct timespec t;
161
  int i;
162
  NRT_TASK_MODEL m;
163
  HARD_TASK_MODEL m_per;
164
  SOFT_TASK_MODEL m_aper;
165
  PID p1, p2, p3, p4, p5;
166
  int k=1;
167
 
168
  srand(7);
169
 
170
  nrt_task_default_model(m);
171
  nrt_task_def_group(m,1);
172
 
173
  p1 = task_create("pippo", pippo, &m, NULL);
174
  if (p1 == NIL)
175
  { kern_printf("Can't create pippo task...\n"); }
176
 
177
  p2 = task_create("pippo2", pippo2, &m, NULL);
178
  if (p2 == NIL)
179
  { kern_printf("Can't create pippo2 task...\n"); }
180
 
181
  hard_task_default_model(m_per);
182
  hard_task_def_mit(m_per,15000);
183
  hard_task_def_wcet(m_per,6200);
184
  hard_task_def_group(m_per,1);
185
  p3 = task_create("asteroide", asteroide, &m_per, NULL);
186
  if (p3 == NIL)
187
  { kern_printf("Can't create asteroide task...\n"); }
188
 
189
  soft_task_default_model(m_aper);
190
  soft_task_def_met(m_aper,10000);
191
  soft_task_def_period(m_aper,100000);
192
  soft_task_def_group(m_aper,1);
193
  soft_task_def_system(m_aper);
194
  soft_task_def_arg(m_aper, 14);
195
  soft_task_def_aperiodic(m_aper);
196
  p4 = task_create("aper", aper, &m_aper, NULL);
197
  if (p4 == NIL)
198
  { kern_printf("Can't create aper task...\n"); }
199
 
200
  soft_task_def_arg(m_aper, 13);
201
  p5 = task_create("aper", aper, &m_aper, NULL);
202
  if (p5 == NIL)
203
  { kern_printf("Can't create aper(2) task...\n"); }
204
 
205
  soft_task_def_arg(m_aper, 12);
206
  p5 = task_create("aper", aper, &m_aper, NULL);
207
  if (p5 == NIL)
208
  { kern_printf("Can't create aper(2) task...\n"); }
209
 
210
  soft_task_def_arg(m_aper, 11);
211
  p5 = task_create("aper", aper, &m_aper, NULL);
212
  if (p5 == NIL)
213
  { kern_printf("Can't create aper(2) task...\n"); }
214
 
215
//  kern_printf("p1=%d p2=%d p3=%d p4=%d\n",p1,p2,p3,p4);
216
  group_activate(1);
217
 
218
 
219
//  task_kill(p2);
220
  i = 1;
221
 
222
  NULL_TIMESPEC(&t);
223
  do {
224
    kern_cli();
225
    ll_gettime(TIME_EXACT, &t);
226
    kern_sti();
227
 
228
    if (i && t.tv_sec == 5) {
229
      task_activate(p4);
230
      task_activate(p5);
231
      i = 0;
232
    }
233
 
234
//    task_kill(p3);
235
  } while (t.tv_sec < 10);
236
  testactive = 0;
237
 
238
  kern_printf("FINE MAIN time=%d useds=%d\n",ll_gettime(TIME_EXACT,NULL),useds);
239
  for (i=0; i<useds; i++)
240
     kern_printf("%6d: pid %-9d stime %-9d reschedule %-9d avail %-9d\n",i,
241
               s_PID[i], s_stime[i].tv_nsec, s_send[i].tv_nsec, s_curr[i]);
242
 
243
  return 0;
244
}