Subversion Repositories shark

Rev

Rev 1628 | Rev 1630 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1627 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
 *   Giacomo Guidi       <giacomo@gandalf.sssup.ti>
10
 *
11
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
12
 *
13
 * http://www.sssup.it
14
 * http://retis.sssup.it
15
 * http://shark.sssup.it
16
 */
17
 
18
/*
19
 * This program is free software; you can redistribute it and/or modify
20
 * it under the terms of the GNU General Public License as published by
21
 * the Free Software Foundation; either version 2 of the License, or
22
 * (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
32
 */
33
 
34
#include "kernel/kern.h"
35
 
36
TASK elastic_test(void *arg) {
37
 
1629 anton 38
  int nbr = (int)arg;
39
 
1627 giacomo 40
  while(1) {
1629 anton 41
    cprintf("%d.", nbr);
1627 giacomo 42
    task_endcycle();
43
  }
44
}
45
 
46
int main(int argc, char **argv)
47
{
1629 anton 48
  ELASTIC_TASK_MODEL e1, e2, e3;
49
  PID el_pid1, el_pid2, el_pid3;
1627 giacomo 50
 
1629 anton 51
  cprintf("Elastic Task Demo (U=0.5 in initfile.c)\n");
1627 giacomo 52
 
1629 anton 53
  cprintf("Creating elastic task with Tmin = 100000, C = 20000, E = 0\n");
54
  elastic_task_default_model(e1);
55
  elastic_task_def_period(e1, 100000, 100000);
56
  elastic_task_def_wcet(e1, 20000);
57
  elastic_task_def_param(e2, 0, PERIOD_SCALING);
58
  elastic_task_def_arg(e1, (void *)1);
59
  el_pid1 = task_create("Elastic1",elastic_test,&e1,NULL);
60
  if (el_pid1 == NIL) {
61
    cprintf("ERROR: Cannot create Elastic1\n");
1627 giacomo 62
    sys_end();
63
  }
1629 anton 64
  task_activate(el_pid1);
1627 giacomo 65
 
1629 anton 66
  cprintf("\nCreating elastic task with Tmin = 200000, C = 80000, E = 2\n");
67
  elastic_task_default_model(e2);
68
  elastic_task_def_period(e2, 200000, 400000);
69
  elastic_task_def_wcet(e2, 80000);
70
  elastic_task_def_param(e2, 2, PERIOD_SCALING);
71
  elastic_task_def_arg(e2, (void *)2);
72
  el_pid2 = task_create("Elastic2",elastic_test,&e2,NULL);
73
  if (el_pid2 == NIL) {
74
    cprintf("ERROR: Cannot create Elastic2\n");
75
    sys_end();
76
  }
77
  task_activate(el_pid2);
1627 giacomo 78
 
1629 anton 79
  cprintf("\nCreating elastic task with Tmin = 400000, C = 40000, E = 1\n");
80
  elastic_task_default_model(e3);
81
  elastic_task_def_period(e3, 400000, 2000000);
82
  elastic_task_def_wcet(e3, 40000);
83
  elastic_task_def_param(e3, 1, PERIOD_SCALING);
84
  elastic_task_def_arg(e3, (void *)3);
85
  el_pid3 = task_create("Elastic3",elastic_test,&e3,NULL);
86
  if (el_pid3 == NIL) {
87
    cprintf("ERROR: Cannot create Elastic3\n");
88
    sys_end();
89
  }
90
  task_activate(el_pid3);
1628 giacomo 91
 
1629 anton 92
 
93
  /* Exit at time t = 5.0 */
94
  struct timespec t;
95
  t.tv_sec = 5;
96
  t.tv_nsec = 0;
97
  kern_event_post(&t, (void(*)(void*))sys_end, NULL);
98
  while(1);
1627 giacomo 99
  return 0;
100
 
101
}