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: test3.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
 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, edfstar_level, edfstar_level2, mybudget, mybudget2;
83
  clear();
84
  EDF_register_level(EDF_ENABLE_ALL);
85
 
86
  cbsstar_level = CBSSTAR_register_level(3, 0);
87
 
88
  mybudget = CBSSTAR_setbudget(cbsstar_level, 2000, 50000);
89
  edfstar_level = EDFSTAR_register_level(mybudget, cbsstar_level);
90
 
91
  mybudget2 = CBSSTAR_setbudget(cbsstar_level, 10000, 25000);
92
  edfstar_level2 = EDFSTAR_register_level(mybudget2, cbsstar_level);
93
 
94
  RR_register_level(RRTICK, RR_MAIN_YES, mb);
95
  dummy_register_level();
96
 
97
  cprintf("edfstar_level=%d, edfstar_level2=%d\n",
98
          edfstar_level,edfstar_level2);
99
 
100
  // for the keyboard...
101
  CBS_register_level(CBS_ENABLE_ALL, 0);
102
 
103
  SEM_register_module();
104
 
105
  CABS_register_module();
106
 
107
  return TICK;
108
}
109
 
110
TASK __init__(void *arg)
111
{
112
  struct multiboot_info *mb = (struct multiboot_info *)arg;
113
 
114
  KEYB_PARMS kparms = BASE_KEYB;
115
 
116
  HARTPORT_init();
117
 
118
  KEYB_init(&kparms);
119
 
120
  __call_main__(mb);
121
 
122
  return (void *)0;
123
}
124
 
125
// --------------------------------------------------
126
// --------------------------------------------------
127
// The Test
128
// --------------------------------------------------
129
// --------------------------------------------------
130
 
131
#include <kernel/kern.h>
132
#include <drivers/keyb.h>
133
#include <semaphore.h>
134
 
135
sem_t s;
136
 
137
void *star(void *arg)
138
{
139
  int j,z;
140
 
141
  for (;;) {
142
    for (z=0; z<5; z++) {
143
      for (j=0; j<60000; j++);
144
      sem_wait(&s);
145
      cputs((char *)arg);
146
      sem_post(&s);
147
    }
148
  }
149
 
150
  return NULL;
151
}
152
 
153
 
154
void create1()
155
{
156
  HARD_TASK_MODEL m1;
157
  PID p1a, p1c;
158
 
159
  hard_task_default_model(m1);
160
  hard_task_def_wcet(m1, 5000);
161
  hard_task_def_group(m1,1);
162
  hard_task_def_periodic(m1);
163
 
164
 
165
 
166
 
167
  hard_task_def_level(m1,2);
168
 
169
  hard_task_def_arg(m1,(void *)"O");
170
  hard_task_def_mit(m1,5000);
171
  p1a = task_create("a", star, &m1, NULL);
172
  if (p1a == -1) {
173
    perror("Could not create task a ...");
174
    sys_end();
175
  }
176
 
177
 
178
  hard_task_def_level(m1,3);
179
 
180
  hard_task_def_arg(m1,(void *)".");
181
  hard_task_def_mit(m1,5000);
182
  p1c = task_create("c", star, &m1, NULL);
183
  if (p1c == -1) {
184
    perror("Could not create task c ...");
185
    sys_end();
186
  }
187
 
188
  group_activate(1);
189
}
190
 
191
void endfun(KEY_EVT *k)
192
{
193
  cprintf("ESC pressed!");
194
 
195
  sys_end();
196
}
197
 
198
int main(int argc, char **argv)
199
{
200
  KEY_EVT k;
201
 
202
  sem_init(&s,0,1);
203
 
204
  k.flag = 0;
205
  k.scan = KEY_ESC;
206
  k.ascii = 27;
207
  keyb_hook(k,endfun);
208
 
209
  create1();
210
 
211
  return 0;
212
}
213