Subversion Repositories shark

Rev

Details | 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
 ------------
19
 CVS :        $Id: perf1.c,v 1.1.1.1 2002-09-02 09:37:48 pj Exp $
20
 
21
 File:        $File$
22
 Revision:    $Revision: 1.1.1.1 $
23
 Last update: $Date: 2002-09-02 09:37:48 $
24
 ------------
25
 
26
 Performance test 1:
27
 
28
 there is one RR task that is preempted N_EDF times by an EDF task.
29
 
30
 the test prints the differences of the execution time.
31
 
32
 the test have to be compiled with the one shot timer, and it does not
33
 use any init file.
34
 
35
**/
36
 
37
/*
38
 * Copyright (C) 2000 Paolo Gai
39
 *
40
 * This program is free software; you can redistribute it and/or modify
41
 * it under the terms of the GNU General Public License as published by
42
 * the Free Software Foundation; either version 2 of the License, or
43
 * (at your option) any later version.
44
 *
45
 * This program is distributed in the hope that it will be useful,
46
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
47
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
48
 * GNU General Public License for more details.
49
 *
50
 * You should have received a copy of the GNU General Public License
51
 * along with this program; if not, write to the Free Software
52
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
53
 *
54
 */
55
 
56
 
57
#include "kernel/kern.h"
58
#include "modules/edf.h"
59
#include "modules/rr.h"
60
#include "modules/dummy.h"
61
 
62
#define TIMESPEC_N        100
63
#define RR_N       1000000000
64
#define EDF_N            2500
65
 
66
 
67
TIME __kernel_register_levels__(void *arg)
68
{
69
  struct multiboot_info *mb = (struct multiboot_info *)arg;
70
 
71
  EDF_register_level(EDF_ENABLE_ALL);
72
  RR_register_level(1000*1000*1000, RR_MAIN_NO, mb);
73
  RR_register_level(10000, RR_MAIN_YES, mb);
74
  dummy_register_level();
75
 
76
  return 300;
77
}
78
 
79
void *crash_RR(void *arg);
80
void *crash_EDF(void *arg);
81
 
82
void *__init__(void *arg)
83
{
84
    int i;
85
 
86
    PID p1,p2;
87
 
88
    HARD_TASK_MODEL m_hard;
89
    NRT_TASK_MODEL  m_nrt;
90
 
91
    TIME t[TIMESPEC_N];
92
 
93
    // JET data
94
    TIME sum, max, curr;
95
    int nact;
96
 
97
 
98
 
99
    hard_task_default_model(m_hard);
100
    hard_task_def_mit      (m_hard,2000);
101
    hard_task_def_wcet     (m_hard,1000);
102
    hard_task_def_group    (m_hard,1);
103
    hard_task_def_ctrl_jet (m_hard);
104
 
105
    nrt_task_default_model (m_nrt);
106
    nrt_task_def_group     (m_nrt,1);
107
    nrt_task_def_ctrl_jet  (m_nrt);
108
 
109
    p1 = task_create("crash_EDF",crash_EDF,&m_hard,NULL);
110
    if (p1 == -1) {
111
        perror("Could not create task <crask_EDF> ...");
112
        sys_end();
113
    }
114
 
115
    p2 = task_create("crash_RR",crash_RR,&m_nrt,NULL);
116
    if (p2 == -1) {
117
        perror("Could not create task <crask_RR> ...");
118
        sys_end();
119
    }
120
 
121
    kern_cli();
122
    /* timespec read time */
123
    for (i=0; i<TIMESPEC_N; i++) {
124
      t[i] = ll_gettime(TIME_EXACT, NULL);
125
    }
126
    kern_sti();
127
 
128
    kern_printf("\n");
129
    for (i=0; i<TIMESPEC_N; i++) {
130
      kern_printf("%d: %ld Û", i, t[i]);
131
    }
132
    kern_printf("\n");
133
 
134
    task_activate(p2);
135
 
136
    jet_getstat(p2, &sum, &max, &nact, &curr);
137
    kern_printf("RR test (alone): sum=%ld, max=%ld, nact=%d, curr=%ld\n",
138
                sum, max, nact, curr);
139
    jet_delstat(p2);
140
 
141
    group_activate(1);
142
 
143
    jet_getstat(p2, &sum, &max, &nact, &curr);
144
    kern_printf("\nRR test  : sum=%ld, max=%ld, nact=%d, curr=%ld\n",
145
                sum, max, nact, curr);
146
    jet_getstat(p1, &sum, &max, &nact, &curr);
147
    kern_printf("EDF test : sum=%ld, max=%ld, nact=%d, curr=%ld\n",
148
                sum, max, nact, curr);
149
 
150
    sys_end();
151
 
152
    return 0;
153
}
154
 
155
void *crash_RR(void *arg)
156
{
157
  int i;
158
 
159
  for (;;) {
160
    for (i=0; i<RR_N; i++);
161
    task_sleep();
162
  }
163
  return 0;
164
}
165
 
166
void *crash_EDF(void *arg)
167
{
168
  int i;
169
 
170
  for (;;) {
171
    for (i=0; i<EDF_N; i++)
172
      task_endcycle();
173
    task_sleep();
174
  }
175
  return 0;
176
}
177
 
178
// not used!!!
179
int main(int argc, char **argv)
180
{
181
  return 0;
182
}
183
 
184
 
185
 
186