Subversion Repositories shark

Rev

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: test9.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 9:
27
 
28
 same as Test 7, with 8 TBS tasks running
29
 
30
 TBS test
31
 
32
**/
33
 
34
/*
35
 * Copyright (C) 2000 Paolo Gai
36
 *
37
 * This program is free software; you can redistribute it and/or modify
38
 * it under the terms of the GNU General Public License as published by
39
 * the Free Software Foundation; either version 2 of the License, or
40
 * (at your option) any later version.
41
 *
42
 * This program is distributed in the hope that it will be useful,
43
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
44
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45
 * GNU General Public License for more details.
46
 *
47
 * You should have received a copy of the GNU General Public License
48
 * along with this program; if not, write to the Free Software
49
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
50
 *
51
 */
52
 
53
#include "kernel/kern.h"
54
 
55
#if !defined(__TEST1__)
56
  THE TEST REQUIRE THE DEFINITION __TEST1__ IN CONFIG.C
57
#endif
58
 
59
struct timespec s_stime[10000];
60
struct timespec s_send[10000];
61
TIME s_curr[10000];
62
PID  s_PID[10000];
63
int useds=0;
64
int testactive=1;
65
 
66
TASK pippo()
67
{
68
  int i;
69
  struct timespec t;
70
  int last = 0;
71
 
72
  do {
73
    kern_cli();
74
    ll_gettime(TIME_EXACT, &t);
75
    kern_sti();
76
  } while (t.tv_nsec <= 30000000L);
77
}
78
 
79
TASK pippo2()
80
{
81
  int i;
82
  struct timespec t;
83
  int last = 0;
84
 
85
  do {
86
    kern_cli();
87
    ll_gettime(TIME_EXACT, &t);
88
    kern_sti();
89
 
90
  } while (t.tv_nsec <= 30000000L);
91
}
92
 
93
TASK asteroide(void)
94
{
95
    int i;
96
    int y = rand() % 7 + 15;
97
 
98
    int load1,j;
99
 
100
    char s[2];
101
 
102
    s[0] = '*'; s[1] = 0;
103
 
104
    /*for (;;)*/ {
105
      i = 1;
106
      while (i < 60) {
107
        load1 = 10000; //8000 + rand()%2000;
108
        for (j=0; j<load1; j++) {
109
          s[0] = '*' + rand() % 100;
110
          puts_xy(i,y,rand()%15+1,s);
111
        }
112
 
113
        task_endcycle();
114
 
115
        if (i==7)  testactive = 0;
116
 
117
        puts_xy(i,y,WHITE," ");
118
        i++;
119
      }
120
    }
121
    //num_aster--;
122
}
123
 
124
TASK aper(void *a)
125
{
126
    int i;
127
    int y;
128
 
129
    int load1,j;
130
 
131
    char s[2];
132
 
133
    y = (int) a;
134
 
135
    s[0] = '*'; s[1] = 0;
136
 
137
    /*for (;;)*/ {
138
      i = 1;
139
      while (i < 60) {
140
        load1 = 100000; //8000 + rand()%2000;
141
        for (j=0; j<load1; j++) {
142
          s[0] = '*' + rand() % 100;
143
          puts_xy(i,y,rand()%15+1,s);
144
        }
145
 
146
        task_sleep();
147
 
148
        puts_xy(i,y,WHITE," ");
149
        i++;
150
      }
151
    }
152
    //num_aster--;
153
}
154
 
155
 
156
int main(int argc, char **argv)
157
{
158
  struct timespec t;
159
  int i;
160
  NRT_TASK_MODEL m;
161
  HARD_TASK_MODEL m_per;
162
  SOFT_TASK_MODEL m_aper;
163
  PID p1, p2, p3, p4, p5;
164
  int k=1;
165
 
166
  srand(7);
167
 
168
  nrt_task_default_model(m);
169
  nrt_task_def_group(m,1);
170
 
171
  p1 = task_create("pippo", pippo, &m, NULL);
172
  if (p1 == NIL)
173
  { kern_printf("Can't create pippo task...\n"); sys_end(); }
174
 
175
  p2 = task_create("pippo2", pippo2, &m, NULL);
176
  if (p2 == NIL)
177
  { kern_printf("Can't create pippo2 task...\n"); sys_end(); }
178
 
179
  hard_task_default_model(m_per);
180
  hard_task_def_wcet(m_per,6200);
181
  hard_task_def_mit(m_per,15000);
182
  hard_task_def_group(m_per,1);
183
  p3 = task_create("asteroide", asteroide, &m_per, NULL);
184
  if (p3 == NIL)
185
  { kern_printf("Can't create asteroide task...\n"); sys_end(); }
186
 
187
  soft_task_default_model(m_aper);
188
  soft_task_def_wcet(m_aper,62000);
189
  soft_task_def_group(m_aper,1);
190
  soft_task_def_system(m_aper);
191
  soft_task_def_arg(m_aper, 14);
192
  soft_task_def_aperiodic(m_aper);
193
  p4 = task_create("aper", aper, &m_aper, NULL);
194
  if (p4 == NIL)
195
  { kern_printf("Can't create aper task...%d \n",errno); sys_end(); }
196
 
197
  soft_task_def_arg(m_aper, 13);
198
  p5 = task_create("aper", aper, &m_aper, NULL);
199
  if (p5 == NIL)
200
  { kern_printf("Can't create aper(2) task...\n"); sys_end(); }
201
 
202
  soft_task_def_arg(m_aper, 12);
203
  p5 = task_create("aper", aper, &m_aper, NULL);
204
  if (p5 == NIL)
205
  { kern_printf("Can't create aper(2) task...\n"); sys_end(); }
206
 
207
  soft_task_def_arg(m_aper, 11);
208
  p5 = task_create("aper", aper, &m_aper, NULL);
209
  if (p5 == NIL)
210
  { kern_printf("Can't create aper(2) task...\n"); sys_end(); }
211
 
212
//  kern_printf("p1=%d p2=%d p3=%d p4=%d\n",p1,p2,p3,p4);
213
  group_activate(1);
214
 
215
 
216
//  task_kill(p2);
217
 
218
  NULL_TIMESPEC(&t);
219
  do {
220
    kern_cli();
221
    ll_gettime(TIME_EXACT, &t);
222
    kern_sti();
223
 
224
//    task_kill(p3);
225
  } while (t.tv_sec < 1);
226
  testactive = 0;
227
/*
228
  kern_printf("FINE MAIN time=%d useds=%d\n",ll_gettime(TIME_EXACT,NULL),useds);
229
  for (i=0; i<useds; i++)
230
     kern_printf("%6d: pid %-9d stime %-9d reschedule %-9d avail %-9d\n",i,
231
               s_PID[i], s_stime[i].tv_nsec, s_send[i].tv_nsec, s_curr[i]);
232
*/
233
  return 0;
234
}