Subversion Repositories shark

Rev

Rev 1089 | 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: test6.c,v 1.2 2003-01-07 17:10:17 pj Exp $
1089 pj 22
 
23
 File:        $File$
1123 pj 24
 Revision:    $Revision: 1.2 $
25
 Last update: $Date: 2003-01-07 17:10:17 $
1089 pj 26
 ------------
27
 
28
 this test shows a set of 5 tasks (+main+dummy+keyboard driver).
29
 
30
 The first 4 tasks are scheduled by a RMSTAR Module, whereas the
31
 fifth one is a standard traditional EDF task. The 4 tasks uses a
32
 budget of 10000/100000.
33
 
34
 if edfstar.c is compiled with edfstar_printf3 active, a couple
35
 (dline, curtime) is showed (in ms).
36
 
37
 if cbsstar.c is compiled with cbsstar_printf3 active, the budget
38
 replenishments are showed.
39
*/
40
 
41
/*
42
 * Copyright (C) 2002 Paolo Gai
43
 *
44
 * This program is free software; you can redistribute it and/or modify
45
 * it under the terms of the GNU General Public License as published by
46
 * the Free Software Foundation; either version 2 of the License, or
47
 * (at your option) any later version.
48
 *
49
 * This program is distributed in the hope that it will be useful,
50
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
51
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
52
 * GNU General Public License for more details.
53
 *
54
 * You should have received a copy of the GNU General Public License
55
 * along with this program; if not, write to the Free Software
56
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
57
 *
58
 */
59
 
60
#include "kernel/kern.h"
61
#include "modules/edf.h"
62
#include "modules/cbs.h"
63
#include "cbsstar.h"
64
#include "rmstar.h"
65
#include "modules/rr.h"
66
#include "modules/dummy.h"
67
 
68
#include "modules/sem.h"
69
#include "modules/hartport.h"
70
#include "modules/cabs.h"
71
 
72
#include "drivers/keyb.h"
73
 
74
 
75
// --------------------------------------------------
76
// --------------------------------------------------
77
// Init Part
78
// --------------------------------------------------
79
// --------------------------------------------------
80
 
81
 
82
/*+ sysyem tick in us +*/
83
#define TICK 0
84
 
85
/*+ RR tick in us +*/
86
#define RRTICK 10000
87
 
88
TIME __kernel_register_levels__(void *arg)
89
{
90
  struct multiboot_info *mb = (struct multiboot_info *)arg;
91
  int cbsstar_level, rmstar_level, mybudget;
92
 
93
  EDF_register_level(EDF_ENABLE_ALL);
94
 
95
  cbsstar_level = CBSSTAR_register_level(3, 0);
96
  mybudget = CBSSTAR_setbudget(cbsstar_level, 10000, 100000);
97
  rmstar_level = RMSTAR_register_level(mybudget, cbsstar_level);
98
 
99
  RR_register_level(RRTICK, RR_MAIN_YES, mb);
100
  dummy_register_level();
101
 
102
  // for the keyboard...
103
  CBS_register_level(CBS_ENABLE_ALL, 0);
104
 
105
  SEM_register_module();
106
 
107
  CABS_register_module();
108
 
109
  return TICK;
110
}
111
 
112
TASK __init__(void *arg)
113
{
114
  struct multiboot_info *mb = (struct multiboot_info *)arg;
115
 
116
  KEYB_PARMS kparms = BASE_KEYB;
117
 
118
  HARTPORT_init();
119
 
120
  //keyb_def_ctrlC(kparms, NULL);
121
  //keyb_def_map(kparms,itaMap);
122
  KEYB_init(&kparms);
123
 
124
  __call_main__(mb);
125
 
126
  return (void *)0;
127
}
128
 
129
// --------------------------------------------------
130
// --------------------------------------------------
131
// The Test
132
// --------------------------------------------------
133
// --------------------------------------------------
134
 
135
 
136
#include <kernel/kern.h>
137
#include <drivers/keyb.h>
138
 
139
void *star(void *arg)
140
{
141
  int i,j;
142
 
143
  for (i=0; i<5; i++) {
144
    for (j=0; j<100000; j++);
145
    cputc('');
146
    cputs((char *)arg);
147
    task_endcycle();
148
  }
149
 
150
  return NULL;
151
}
152
 
153
void *edftask(void *arg)
154
{
155
  int i,j;
156
 
157
  for (i=0; i<5; i++) {
158
    for (j=0; j<100000; j++);
159
    cputc('');
160
    cputs((char *)arg);
161
    task_endcycle();
162
  }
163
 
164
  return NULL;
165
}
166
 
167
void create1()
168
{
169
  HARD_TASK_MODEL m1, m2;
170
  PID p1a, p1b, p1c, p1d, p2;
171
 
172
  hard_task_default_model(m1);
173
  hard_task_def_wcet(m1, 5000);
174
  hard_task_def_level(m1,2);
175
  hard_task_def_group(m1,1);
176
  hard_task_def_periodic(m1);
177
 
178
  hard_task_def_arg(m1,(void *)"a");
179
  hard_task_def_mit(m1,10000);
180
  p1a = task_create("a", star, &m1, NULL);
181
  if (p1a == -1) {
182
    perror("Could not create task a ...");
183
    sys_end();
184
  }
185
 
186
  hard_task_def_arg(m1,(void *)"b");
187
  hard_task_def_mit(m1,15000);
188
  p1b = task_create("b", star, &m1, NULL);
189
  if (p1b == -1) {
190
    perror("Could not create task b ...");
191
    sys_end();
192
  }
193
 
194
  hard_task_def_arg(m1,(void *)"c");
195
  hard_task_def_mit(m1,20000);
196
  p1c = task_create("c", star, &m1, NULL);
197
  if (p1c == -1) {
198
    perror("Could not create task c ...");
199
    sys_end();
200
  }
201
 
202
  hard_task_def_arg(m1,(void *)"d");
203
  hard_task_def_mit(m1,30000);
204
  p1d = task_create("d", star, &m1, NULL);
205
  if (p1d == -1) {
206
    perror("Could not create task d ...");
207
    sys_end();
208
  }
209
 
210
  hard_task_default_model(m2);
211
  hard_task_def_mit(m2,50000); // the budget has dline 100,000!
212
  hard_task_def_wcet(m2, 5000);
213
  hard_task_def_arg(m2,(void *)"");
214
  hard_task_def_group(m2,1);
215
  hard_task_def_periodic(m2);
216
 
217
  p2 = task_create("2", edftask, &m2, NULL);
218
  if (p2 == -1) {
219
    perror("Could not create task edf ...");
220
    sys_end();
221
  }
222
 
223
  cprintf("stars=%d %d %d %d, star2=%d\n", p1a, p1b, p1c, p1d, p2);
224
 
225
  group_activate(1);
226
}
227
 
228
int main(int argc, char **argv)
229
{
230
  char c;
231
 
232
  clear();
233
 
234
  cprintf("Hello, world!");
235
 
236
  create1();
237
 
238
  do {
239
    c =keyb_getch(BLOCK);
240
  } while (c != ESC);
241
 
242
  cprintf("ESC pressed!");
243
 
244
  sys_end();
245
 
246
  return 0;
247
}
248