Subversion Repositories shark

Rev

Rev 1116 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1089 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
 ------------
1123 pj 21
 CVS :        $Id: testiq.c,v 1.3 2003-01-07 17:10:17 pj Exp $
1089 pj 22
 
23
 File:        $File$
1123 pj 24
 Revision:    $Revision: 1.3 $
25
 Last update: $Date: 2003-01-07 17:10:17 $
1089 pj 26
 ------------
27
 
28
 The purpose of this test is to show that two budgets with different
29
 period and budgets schedules correctly.
30
 
31
 2 never ending tasks are involved
1116 pj 32
 
33
 This test cannot compile because of the fact that QUEUE and QQUEUE
34
 types does not exist anymore!
1089 pj 35
*/
36
 
37
/*
38
 * Copyright (C) 2002 Paolo Gai
39
 *
40
 * This program is free software; you can redistribute it and/or modify
41
 * it under the terms of the GNU General Public License as published by
42
 * the Free Software Foundation; either version 2 of the License, or
43
 * (at your option) any later version.
44
 *
45
 * This program is distributed in the hope that it will be useful,
46
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
48
 * GNU General Public License for more details.
49
 *
50
 * You should have received a copy of the GNU General Public License
51
 * along with this program; if not, write to the Free Software
52
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
53
 *
54
 */
55
 
56
#include "kernel/kern.h"
57
#include "modules/edf.h"
58
#include "modules/cbs.h"
59
#include "cbsstar.h"
60
#include "edfstar.h"
61
#include "modules/rr.h"
62
#include "modules/dummy.h"
63
 
64
#include "modules/sem.h"
65
#include "modules/hartport.h"
66
#include "modules/cabs.h"
67
 
68
#include "drivers/keyb.h"
69
 
70
// --------------------------------------------------
71
// --------------------------------------------------
72
// Init Part
73
// --------------------------------------------------
74
// --------------------------------------------------
75
 
76
/*+ sysyem tick in us +*/
77
#define TICK 0
78
 
79
/*+ RR tick in us +*/
80
#define RRTICK 10000
81
 
82
TIME __kernel_register_levels__(void *arg)
83
{
84
  struct multiboot_info *mb = (struct multiboot_info *)arg;
85
 
86
  clear();
87
 
88
  EDF_register_level(EDF_ENABLE_ALL);
89
 
90
  RR_register_level(RRTICK, RR_MAIN_YES, mb);
91
  dummy_register_level();
92
 
93
  // for the keyboard...
94
  CBS_register_level(CBS_ENABLE_ALL, 0);
95
 
96
  SEM_register_module();
97
 
98
  CABS_register_module();
99
 
100
  return TICK;
101
}
102
 
103
TASK __init__(void *arg)
104
{
105
  struct multiboot_info *mb = (struct multiboot_info *)arg;
106
 
107
  KEYB_PARMS kparms = BASE_KEYB;
108
 
109
  HARTPORT_init();
110
 
111
  //keyb_def_ctrlC(kparms, NULL);
112
  //keyb_def_map(kparms,itaMap);
113
  KEYB_init(&kparms);
114
 
115
  __call_main__(mb);
116
 
117
  return (void *)0;
118
}
119
 
120
// --------------------------------------------------
121
// --------------------------------------------------
122
// The Test
123
// --------------------------------------------------
124
// --------------------------------------------------
125
 
126
 
127
#include <kernel/kern.h>
128
#include <drivers/keyb.h>
129
#include "iqueue.h"
130
 
131
sem_t s;
132
 
133
PID p2,p3,p4;
134
 
135
void *star(void *arg)
136
{
137
  int j;
138
  TIME last[5];
139
 
140
  QUEUE i = NIL;
141
  IQUEUE ii;
142
 
143
  q_timespec_insert(p2,&i);
144
  q_timespec_insert(p3,&i);
145
 
146
  iq_init(&ii,NULL,0);
147
  *iq_query_timespec(p2,&ii) = proc_table[p2].timespec_priority;
148
  *iq_query_timespec(p3,&ii) = proc_table[p3].timespec_priority;
149
  *iq_query_timespec(p4,&ii) = proc_table[p4].timespec_priority;
150
  iq_timespec_insert(p2,&ii);
151
  iq_timespec_insert(p3,&ii);
152
 
153
  cprintf("p2=%ld.%ld\n",proc_table[p2].timespec_priority.tv_sec,proc_table[p2].timespec_priority.tv_nsec/1000);
154
  cprintf("p3=%ld.%ld\n",proc_table[p3].timespec_priority.tv_sec,proc_table[p3].timespec_priority.tv_nsec/1000);
155
  cprintf("p4=%ld.%ld\n",proc_table[p4].timespec_priority.tv_sec,proc_table[p4].timespec_priority.tv_nsec/1000);
156
 
157
  task_endcycle();
158
 
159
  for (j=0; j<200000; j++) {
160
    q_timespec_insert(p4,&i);
161
    q_extract(p4,&i);
162
  }
163
 
164
 
165
  task_endcycle();
166
 
167
  for (j=0; j<200000; j++) {
168
    iq_timespec_insert(p4,&ii);
169
    iq_extract(p4,&ii);
170
  }
171
 
172
  task_endcycle();
173
 
174
  jet_gettable(exec_shadow, &last[0], 3);
175
 
176
  cprintf("\ninit=%d queue=%d iqueue=%d\n",
177
          (int)last[0], (int)last[1], (int)last[2]);
178
 
179
  sys_end();
180
  return NULL;
181
}
182
 
183
void *fake(void *arg)
184
{
185
  cputs("#");
186
  task_endcycle();
187
 
188
  return NULL;
189
}
190
 
191
 
192
void create1()
193
{
194
  HARD_TASK_MODEL m1;
195
  PID p1a;
196
 
197
  hard_task_default_model(m1);
198
  hard_task_def_wcet(m1, 500000);
199
  hard_task_def_group(m1,1);
200
  hard_task_def_periodic(m1);
201
  hard_task_def_mit(m1,1000000);
202
  hard_task_def_ctrl_jet(m1);
203
  p1a = task_create("a", star, &m1, NULL);
204
  if (p1a == -1) {
205
    perror("Could not create task a ...");
206
    sys_end();
207
  }
208
 
209
  hard_task_default_model(m1);
210
  hard_task_def_wcet(m1, 5000);
211
  hard_task_def_aperiodic(m1);
212
  hard_task_def_group(m1,1);
213
 
214
  hard_task_def_mit(m1,100000);
215
  p2 = task_create("a", fake, &m1, NULL);
216
  if (p1a == -1) {
217
    perror("Could not create task a ...");
218
    sys_end();
219
  }
220
 
221
  hard_task_def_mit(m1,100001);
222
  p3 = task_create("a", fake, &m1, NULL);
223
  if (p1a == -1) {
224
    perror("Could not create task a ...");
225
    sys_end();
226
  }
227
 
228
  hard_task_def_mit(m1,100002);
229
  p4 = task_create("a", fake, &m1, NULL);
230
  if (p1a == -1) {
231
    perror("Could not create task a ...");
232
    sys_end();
233
  }
234
 
235
  group_activate(1);
236
}
237
 
238
void endfun(KEY_EVT *k)
239
{
240
  cprintf("ESC pressed!");
241
 
242
  sys_end();
243
}
244
 
245
int main(int argc, char **argv)
246
{
247
  KEY_EVT k;
248
 
249
  sem_init(&s,0,1);
250
 
251
  k.flag = 0;
252
  k.scan = KEY_ESC;
253
  k.ascii = 27;
254
  keyb_hook(k,endfun);
255
 
256
  create1();
257
 
258
  return 0;
259
}
260