Subversion Repositories shark

Rev

Rev 1085 | Go to most recent revision | 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
 ------------
19
 CVS :        $Id: test3.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
 Test Number 3:
27
 task_cleanup_push
28
 task_cleanup_pop
29
 
30
 It may print many 0 and then only one 1
31
 
32
**/
33
 
34
/*
35
 * Copyright (C) 2000 Paolo Gai
36
 *
37
 * This program is free software; you can redistribute it and/or modify
38
 * it under the terms of the GNU General Public License as published by
39
 * the Free Software Foundation; either version 2 of the License, or
40
 * (at your option) any later version.
41
 *
42
 * This program is distributed in the hope that it will be useful,
43
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
44
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45
 * GNU General Public License for more details.
46
 *
47
 * You should have received a copy of the GNU General Public License
48
 * along with this program; if not, write to the Free Software
49
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
50
 *
51
 */
52
 
53
#include "kernel/kern.h"
54
 
55
#if !defined(__TEST1__)
56
  THE TEST REQUIRE THE DEFINITION __TEST1__ IN CONFIG.C
57
#endif
58
 
59
struct timespec s_stime[10000];
60
struct timespec s_send[10000];
61
TIME s_curr[10000];
62
PID  s_PID[10000];
63
int useds=0;
64
int testactive=1;
65
 
66
 
67
void fun1(void *p)
68
{
69
  kern_printf("лл %d лл",(int)p);
70
}
71
 
72
 
73
TASK pippo()
74
{
75
  int i;
76
  struct timespec t;
77
  int last = 0;
78
  task_cleanup_push(fun1,(void *)1);
79
  do {
80
    kern_cli();
81
    ll_gettime(TIME_EXACT, &t);
82
    kern_sti();
83
 
84
    if (t.tv_nsec > 5000000)
85
    {
86
      task_testcancel();
87
 
88
      task_cleanup_push(fun1,(void *)-1);
89
      task_cleanup_push(fun1,(void *)0);
90
      task_cleanup_pop(1);
91
      task_cleanup_pop(0);
92
    }
93
    task_delay(1000);
94
 
95
  } while (t.tv_nsec <= 30000000L);
96
  task_cleanup_pop(1);
97
}
98
 
99
 
100
 
101
int main(int argc, char **argv)
102
{
103
  struct timespec t;
104
  NRT_TASK_MODEL m;
105
  PID p2,p3;
106
  int k=1;
107
  int i;
108
 
109
  nrt_task_default_model(m);
110
  nrt_task_def_group(m,1);
111
 
112
  p2 = task_create("pippo2", pippo, &m, NULL);
113
  if (p2 == NIL)
114
  { kern_printf("Can't create pippo2 task...\n"); return 1; }
115
 
116
  group_activate(1);
117
 
118
 
119
  NULL_TIMESPEC(&t);
120
  do {
121
    kern_cli();
122
    ll_gettime(TIME_EXACT, &t);
123
    kern_sti();
124
 
125
    if (t.tv_nsec > 10000000) task_kill(p2);
126
  } while (t.tv_nsec <= 20000000L);
127
  testactive = 0;
128
 
129
  return 0;
130
 
131
  kern_printf("FINE MAIN time=%d useds=%d\n",ll_gettime(TIME_EXACT,NULL),useds);
132
  for (i=0; i<useds; i++)
133
     kern_printf("%6d: pid %6d stime %6d reschedule %6d avail %6d\n",i,
134
               s_PID[i], s_stime[i].tv_nsec, s_send[i].tv_nsec, s_curr[i]);
135
 
136
  return 0;
137
}