Subversion Repositories shark

Rev

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

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