Subversion Repositories shark

Rev

Details | 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: testact.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
 
29
/*
30
 * Copyright (C) 2001 Paolo Gai
31
 *
32
 * This program is free software; you can redistribute it and/or modify
33
 * it under the terms of the GNU General Public License as published by
34
 * the Free Software Foundation; either version 2 of the License, or
35
 * (at your option) any later version.
36
 *
37
 * This program is distributed in the hope that it will be useful,
38
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
39
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40
 * GNU General Public License for more details.
41
 *
42
 * You should have received a copy of the GNU General Public License
43
 * along with this program; if not, write to the Free Software
44
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
45
 *
46
 */
47
 
48
/* the demo tests EDFACT with my Celeron 366 Mhz.
49
Aster1 meet all wcets and all deadlines
50
Aster2 miss all wcets but hits all the deadlines
51
Aster3 blocks on a semaphore so it miss all the deadlines and it accumulates
52
       pending activations
53
Aster4 does 5 states:
54
       1: is a cycle, long enough to cope a little more than 2 periods
55
       2-5: like aster1, they meets all the wcet and deadlines
56
       the debug pattern is something like
57
       WDDEEeIeIeI
58
       W wcet violated
59
       D deadline miss event
60
       E endcycle with automatic reactivation due to pending activations
61
       e normal endcycle
62
       I normal reactivation event
63
 
64
 
65
*/
66
 
67
 
68
#include <kernel/kern.h>
69
#include <semaphore.h>
70
#include "edfact.h"
71
 
72
PID p1,p2,p3,p4;
73
 
74
sem_t sem;
75
 
76
#define ASTER_LIM       77
77
 
78
TASK aster1(void *arg)
79
{
80
    int i = 10;
81
    int y = 10+exec_shadow;
82
 
83
    printf_xy(1,y,WHITE,"%d", exec_shadow);
84
    while (i < ASTER_LIM) {
85
        puts_xy(i,y,WHITE,"*");
86
        task_endcycle();
87
 
88
        puts_xy(i,y,WHITE," ");
89
        i++;
90
    }
91
 
92
    return 0;
93
}
94
 
95
TASK aster2(void *arg)
96
{
97
    int i = 10;
98
    int y = 10+exec_shadow;
99
    int x;
100
 
101
    printf_xy(1,y,WHITE,"%d", exec_shadow);
102
    while (i < ASTER_LIM) {
103
        puts_xy(i,y,WHITE,"*");
104
        for(x=0; x<1000000; x++);
105
        task_endcycle();
106
 
107
        puts_xy(i,y,WHITE," ");
108
        i++;
109
    }
110
 
111
    return 0;
112
}
113
 
114
TASK aster3(void *arg)
115
{
116
    int i = 10;
117
    int y = 10+exec_shadow;
118
 
119
    printf_xy(1,y,WHITE,"%d", exec_shadow);
120
    while (i < ASTER_LIM) {
121
        puts_xy(i,y,WHITE,"*");
122
        sem_wait(&sem);
123
        task_endcycle();
124
 
125
        puts_xy(i,y,WHITE," ");
126
        i++;
127
    }
128
 
129
    return 0;
130
}
131
 
132
TASK aster4(void *arg)
133
{
134
    int i = 10;
135
    int y = 10+exec_shadow;
136
    int x;
137
    int flag = 0;
138
 
139
    printf_xy(1,y,WHITE,"%d", exec_shadow);
140
    while (i < ASTER_LIM) {
141
        puts_xy(i,y,WHITE,"*");
142
 
143
        switch (flag) {
144
        case 0:
145
          kern_printf("!");
146
          for(x=0; x<5000000; x++) flag=1;
147
          break;
148
        case 1:
149
          flag = 2;
150
          break;
151
        case 2:
152
          flag = 3;
153
          break;
154
        case 3:
155
          flag = 4;
156
          break;
157
        case 4:
158
          flag = 0;
159
          break;
160
        }
161
 
162
        task_endcycle();
163
 
164
        puts_xy(i,y,WHITE," ");
165
        i++;
166
    }
167
 
168
    return 0;
169
}
170
 
171
 
172
 
173
TASK clock()
174
{
175
    printf_xy(50,19,WHITE,"PID miss wcet nact");
176
    while(1) {
177
        printf_xy(50,20,WHITE,"%3d %4d %4d %4d",
178
                  p1, EDFACT_get_dline_miss(p1),
179
                      EDFACT_get_wcet_miss(p1),
180
                      EDFACT_get_nact(p1));
181
        printf_xy(50,21,WHITE,"%3d %4d %4d %4d",
182
                  p2, EDFACT_get_dline_miss(p2),
183
                      EDFACT_get_wcet_miss(p2),
184
                      EDFACT_get_nact(p2));
185
        printf_xy(50,22,WHITE,"%3d %4d %4d %4d",
186
                  p3, EDFACT_get_dline_miss(p3),
187
                      EDFACT_get_wcet_miss(p3),
188
                      EDFACT_get_nact(p3));
189
        printf_xy(50,23,WHITE,"%3d %4d %4d %4d",
190
                  p4, EDFACT_get_dline_miss(p4),
191
                      EDFACT_get_wcet_miss(p4),
192
                      EDFACT_get_nact(p4));
193
    }
194
}
195
 
196
int main(int argc, char **argv)
197
{
198
    NRT_TASK_MODEL n;
199
 
200
    HARD_TASK_MODEL m;
201
 
202
    kern_printf("\nCtrl-C = end demo\n");
203
 
204
    hard_task_default_model(m);
205
    hard_task_def_mit(m,200000);
206
    hard_task_def_group(m,1);
207
 
208
    sem_init(&sem,0,0);
209
 
210
    hard_task_def_wcet(m,2000);
211
    p1 = task_create("1",aster1,&m,NULL);
212
    if (p1 == -1) {
213
        perror("Aster.C(main): Could not create task <aster> ...");
214
        sys_end();
215
    }
216
 
217
    hard_task_def_wcet(m,2000);
218
    p2 = task_create("1",aster2,&m,NULL);
219
    if (p2 == -1) {
220
        perror("Aster.C(main): Could not create task <aster> ...");
221
        sys_end();
222
    }
223
 
224
    hard_task_def_wcet(m,2000);
225
    p3 = task_create("1",aster3,&m,NULL);
226
    if (p3 == -1) {
227
        perror("Aster.C(main): Could not create task <aster> ...");
228
        sys_end();
229
    }
230
 
231
    hard_task_def_mit(m,20000);
232
    hard_task_def_wcet(m,500);
233
    p4 = task_create("1",aster4,&m,NULL);
234
    if (p4 == -1) {
235
        perror("Aster.C(main): Could not create task <aster> ...");
236
        sys_end();
237
    }
238
 
239
    group_activate(1);
240
 
241
    nrt_task_default_model(n);
242
    task_activate(task_create("Clock",clock,&n,NULL));
243
    return 0;
244
}
245