Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1085 pj 1
/*
2
 * Project: HARTIK (HA-rd R-eal TI-me K-ernel)
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *               Gerardo Lamastra <gerardo@sssup.it>
6
 *
7
 * Authors     : Paolo Gai <pj@hartik.sssup.it>
8
 * (see authors.txt for full list of hartik's authors)
9
 *
10
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
11
 *
12
 * http://www.sssup.it
13
 * http://retis.sssup.it
14
 * http://hartik.sssup.it
15
 */
16
 
17
/**
18
 ------------
1108 pj 19
 CVS :        $Id: test1st.c,v 1.2 2002-11-11 07:55:13 pj Exp $
1085 pj 20
 
21
 File:        $File$
1108 pj 22
 Revision:    $Revision: 1.2 $
23
 Last update: $Date: 2002-11-11 07:55:13 $
1085 pj 24
 ------------
25
 
26
 
27
**/
28
 
29
/*
30
 * Copyright (C) 2000 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
#include "kernel/kern.h"
49
#include "static.h"
50
#include <math.h>
51
#include <string.h>
52
 
53
int theend = 0;
54
 
55
void *mytask(void *arg)
56
{
57
  struct timespec t;
58
 
59
  for (;;)
60
  {
61
    sys_gettime(&t);
62
 
63
    cprintf("I am task %s at time %d.%d\n", (char *)arg, (int)t.tv_sec, (int)t.tv_nsec);
64
 
65
    theend++;
66
 
67
    if (theend > 10) sys_end();
68
 
69
    task_endcycle();
70
  }
71
 
72
}
73
 
74
 
75
int main(int argc, char **argv)
76
{
77
    PID p1;
78
 
79
    STATIC_TASK_MODEL m;
80
 
1108 pj 81
    struct timespec my_time, h, o;
1085 pj 82
 
83
    my_time.tv_nsec=0;
84
 
85
 
86
    my_time.tv_sec = 0;
87
    my_time.tv_nsec = 500000000;
88
    static_task_default_model(m, my_time);
89
    static_task_def_arg(m, "A");
90
 
91
    p1 = task_create("TaskA",mytask,&m,NULL);
92
    if (p1 == -1) {
93
        perror("Could not create task <A> ...");
94
        sys_end();
95
    }
96
 
97
    my_time.tv_sec = 1;
98
    my_time.tv_nsec = 0;
99
    static_task_default_model(m, my_time);
100
    static_task_def_arg(m, "B");
101
 
102
    p1 = task_create("TaskB",mytask,&m,NULL);
103
    if (p1 == -1) {
104
        perror("Could not create task <B> ...");
105
        sys_end();
106
    }
107
 
108
    my_time.tv_sec = 1;
109
    my_time.tv_nsec = 500000000;
110
    static_task_default_model(m, my_time);
111
    static_task_def_arg(m, "C");
112
 
113
    p1 = task_create("TaskC",mytask,&m,NULL);
114
    if (p1 == -1) {
115
        perror("Could not create task <C> ...");
116
        sys_end();
117
    }
118
 
119
    h.tv_sec = 3;
120
    h.tv_nsec = 0;
121
 
122
    o.tv_sec = 1;
123
    o.tv_nsec = 0;
124
 
125
    STATIC_start(0, &h, &o);
126
 
127
    return 0;
128
}
129