Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1624 giacomo 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: test4.c,v 1.1.1.1 2004-05-24 17:54:51 giacomo Exp $
22
 
23
 File:        $File$
24
 Revision:    $Revision: 1.1.1.1 $
25
 Last update: $Date: 2004-05-24 17:54:51 $
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
32
*/
33
 
34
/*
35
 * Copyright (C) 2002 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
#include "modules/edf.h"
55
#include "modules/cbs.h"
56
#include "cbsstar.h"
57
#include "edfstar.h"
58
#include "modules/rr.h"
59
#include "modules/dummy.h"
60
 
61
#include "modules/sem.h"
62
#include "modules/hartport.h"
63
#include "modules/cabs.h"
64
 
65
#include "drivers/keyb.h"
66
 
67
// --------------------------------------------------
68
// --------------------------------------------------
69
// Init Part
70
// --------------------------------------------------
71
// --------------------------------------------------
72
 
73
/*+ sysyem tick in us +*/
74
#define TICK 0
75
 
76
/*+ RR tick in us +*/
77
#define RRTICK 10000
78
 
79
TIME __kernel_register_levels__(void *arg)
80
{
81
  struct multiboot_info *mb = (struct multiboot_info *)arg;
82
  int cbsstar_level;
83
  int edfstar_level, edfstar_level2, edfstar_level3;
84
  int mybudget, mybudget2;
85
 
86
  clear();
87
 
88
  EDF_register_level(EDF_ENABLE_ALL);
89
 
90
  cbsstar_level = CBSSTAR_register_level(3, 0);
91
 
92
  mybudget = CBSSTAR_setbudget(cbsstar_level, 2000, 50000);
93
  edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level);
94
 
95
  mybudget2 = CBSSTAR_setbudget(cbsstar_level, 10000, 25000);
96
  edfstar_level2 = EDFSTAR_register_level(mybudget2, cbsstar_level);
97
  edfstar_level3 = EDFSTAR_register_level(mybudget2, cbsstar_level);
98
 
99
  RR_register_level(RRTICK, RR_MAIN_YES, mb);
100
  dummy_register_level();
101
 
102
  cprintf("edfstar_level=%d, edfstar_level2=%d\n",
103
          edfstar_level,edfstar_level2);
104
 
105
  // for the keyboard...
106
  CBS_register_level(CBS_ENABLE_ALL, 0);
107
 
108
  SEM_register_module();
109
 
110
  CABS_register_module();
111
 
112
  return TICK;
113
}
114
 
115
TASK __init__(void *arg)
116
{
117
  struct multiboot_info *mb = (struct multiboot_info *)arg;
118
 
119
  KEYB_PARMS kparms = BASE_KEYB;
120
 
121
  HARTPORT_init();
122
 
123
  //keyb_def_ctrlC(kparms, NULL);
124
  //keyb_def_map(kparms,itaMap);
125
  KEYB_init(&kparms);
126
 
127
  __call_main__(mb);
128
 
129
  return (void *)0;
130
}
131
 
132
// --------------------------------------------------
133
// --------------------------------------------------
134
// The Test
135
// --------------------------------------------------
136
// --------------------------------------------------
137
 
138
#include <kernel/kern.h>
139
#include <drivers/keyb.h>
140
#include <semaphore.h>
141
 
142
sem_t s;
143
 
144
void *star(void *arg)
145
{
146
  int j,z;
147
 
148
  for (;;) {
149
    for (z=0; z<50; z++) {
150
      for (j=0; j<60000; j++);
151
//      sem_wait(&s);
152
      cputs((char *)arg);
153
//      sem_post(&s);
154
    }
155
    task_endcycle();
156
  }
157
 
158
  return NULL;
159
}
160
 
161
 
162
void create1()
163
{
164
  HARD_TASK_MODEL m1;
165
  PID p1a, p1b, p1c;
166
 
167
  hard_task_default_model(m1);
168
  hard_task_def_wcet(m1, 5000);
169
  hard_task_def_group(m1,1);
170
  hard_task_def_periodic(m1);
171
 
172
 
173
 
174
 
175
  hard_task_def_level(m1,2);
176
 
177
  hard_task_def_arg(m1,(void *)"O");
178
  hard_task_def_mit(m1,5000);
179
  p1a = task_create("a", star, &m1, NULL);
180
  if (p1a == -1) {
181
    perror("Could not create task a ...");
182
    sys_end();
183
  }
184
 
185
 
186
  hard_task_def_level(m1,3);
187
 
188
  hard_task_def_arg(m1,(void *)".");
189
  hard_task_def_mit(m1,5000);
190
  p1b = task_create("b", star, &m1, NULL);
191
  if (p1b == -1) {
192
    perror("Could not create task c ...");
193
    sys_end();
194
  }
195
 
196
  hard_task_def_level(m1,4);
197
 
198
  hard_task_def_arg(m1,(void *)",");
199
  hard_task_def_mit(m1,5000);
200
  p1c = task_create("c", star, &m1, NULL);
201
  if (p1c == -1) {
202
    perror("Could not create task c ...");
203
    sys_end();
204
  }
205
 
206
  group_activate(1);
207
}
208
 
209
void endfun(KEY_EVT *k)
210
{
211
  cprintf("ESC pressed!");
212
 
213
  sys_end();
214
}
215
 
216
int main(int argc, char **argv)
217
{
218
  KEY_EVT k;
219
 
220
  sem_init(&s,0,1);
221
 
222
  k.flag = 0;
223
  k.scan = KEY_ESC;
224
  k.ascii = 27;
225
  keyb_hook(k,endfun);
226
 
227
  create1();
228
 
229
  return 0;
230
}
231