Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1085 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
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
/**
22
 ------------
23
 CVS :        $Id: slshtest.c,v 1.1.1.1 2002-09-02 09:37:41 pj Exp $
24
 
25
 File:        $File$
26
 Revision:    $Revision: 1.1.1.1 $
27
 Last update: $Date: 2002-09-02 09:37:41 $
28
 ------------
29
 
30
 Slot shifting test
31
 
32
 
33
**/
34
 
35
/*
36
 * Copyright (C) 2000 Paolo Gai and Tomas Lennvall
37
 *
38
 * This program is free software; you can redistribute it and/or modify
39
 * it under the terms of the GNU General Public License as published by
40
 * the Free Software Foundation; either version 2 of the License, or
41
 * (at your option) any later version.
42
 *
43
 * This program is distributed in the hope that it will be useful,
44
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
46
 * GNU General Public License for more details.
47
 *
48
 * You should have received a copy of the GNU General Public License
49
 * along with this program; if not, write to the Free Software
50
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
51
 *
52
 */
53
 
54
#include <kernel/config.h>
55
#include "kernel/kern.h"
56
#include "slsh.h"
57
#include "drivers/keyb.h"
58
 
59
/* a slot length of 100 ms */
60
#define SLOT_LENGTH 100000
61
 
62
 
63
TASK static1(void)
64
{
65
        int i = 0;
66
 
67
        kern_printf("Static1\n");
68
        while(sys_gettime(NULL) < 10000) i++;
69
 
70
        return 0;
71
}
72
 
73
TASK static2(void)
74
{
75
        int i = 0;
76
 
77
        kern_printf("Static2\n");
78
        while(sys_gettime(NULL) < 10000) i++;
79
 
80
        return 0;
81
}
82
 
83
 
84
TASK static3(void)
85
{
86
        kern_printf("Static3\n");
87
 
88
        return 0;
89
}
90
 
91
void my_end(KEY_EVT *e)
92
{
93
        sys_end();
94
}
95
 
96
int main(int argc, char** argv)
97
{
98
        STATIC_TASK_MODEL s;
99
        //      HARD_TASK_MODEL h_aper;
100
        //      SOFT_TASK_MODEL u;
101
        PID p1,p2,p3;
102
        struct timespec x;
103
 
104
        KEY_EVT emerg;
105
 
106
        kern_cli();
107
        x.tv_sec=5;
108
        kern_event_post(&x,(void (*)(void *))sys_end,NULL);
109
        kern_sti();
110
 
111
        //keyb_set_map(itaMap);
112
        emerg.ascii = 'x';
113
        emerg.scan = KEY_X;
114
        emerg.flag = ALTL_BIT;
115
        keyb_hook(emerg,my_end);
116
 
117
        /* set som variables in the scheduling level */
118
        SLSH_set_interval(0, 0, 8, 5);
119
        SLSH_set_interval(0, 8, 17, 7);
120
        SLSH_set_interval(0, 17, 20, 1);
121
 
122
        SLSH_set_variables(0, SLOT_LENGTH);
123
 
124
        static_task_default_model(s);
125
        static_task_def_group(s, 1);
126
 
127
        /* define time i ms */
128
        /* static1 task */
129
        static_task_def_est(s, 0);
130
        static_task_def_dabs(s, 800000);
131
        static_task_def_wcet(s, 500000);
132
        static_task_def_interval(s, 0);
133
 
134
        kern_printf("In main, before task creation\n");
135
 
136
        p1 = task_create("Static 1", static1, &s, NULL);
137
        if(p1 == NIL)
138
                kern_printf("Cannot create: Static1!\n");
139
 
140
        /* Static2 task */
141
        static_task_def_est(s, 800000);
142
        static_task_def_dabs(s, 1700000);
143
        static_task_def_wcet(s, 700000);
144
        static_task_def_interval(s, 1);
145
 
146
        p2 = task_create("Static 2", static2, &s, NULL);
147
        if(p2 == NIL)
148
                kern_printf("Cannot create: Static2!\n");
149
 
150
        /* Static3 task */
151
        static_task_def_est(s, 1700000);
152
        static_task_def_dabs(s, 2000000);
153
        static_task_def_wcet(s, 100000);
154
        static_task_def_interval(s, 2);
155
 
156
 
157
        p3 = task_create("Static3", static3, &s, NULL);
158
        if(p3 == NIL)
159
                kern_printf("Cannot create: Static3!\n");
160
 
161
 
162
        /* End task */
163
        /*hard_task_default_model(h_aper);
164
 
165
 
166
        hard_task_def_wcet(h_aper, 100000);
167
        */
168
        kern_printf("After task creation\n");
169
 
170
        group_activate(1);
171
 
172
        return 0;
173
}