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: testu.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 ?? (U):
27
 
28
 this test is a simple main() function with one other task.
29
 
30
 This test verify the correctness of the internal_sem functions.
31
 
32
 
33
**/
34
 
35
/*
36
 * Copyright (C) 2000 Paolo Gai
37
 *
38
 * This program is free software; you can redistribute it and/or modify
39
 * it under the terms of the GNU General Public License as published by
40
 * the Free Software Foundation; either version 2 of the License, or
41
 * (at your option) any later version.
42
 *
43
 * This program is distributed in the hope that it will be useful,
44
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
45
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
46
 * GNU General Public License for more details.
47
 *
48
 * You should have received a copy of the GNU General Public License
49
 * along with this program; if not, write to the Free Software
50
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
51
 *
52
 */
53
 
54
#include "kernel/kern.h"
55
 
56
#include <kernel/int_sem.h>
57
 
58
internal_sem_t s;
59
 
60
TASK pippo(void *a)
61
{
62
  int i=0;
63
  struct timespec t;
64
//  int last = 0;
65
 
66
  do {
67
    kern_cli();
68
    ll_gettime(TIME_EXACT, &t);
69
    kern_sti();
70
 
71
    if (i==0 && t.tv_sec == (int)a) {
72
      i = 1;
73
      kern_printf("before internal_sem_wait %d\n",(int)a);
74
      internal_sem_wait(&s);
75
      kern_printf("after internal_sem_wait %d\n",(int)a);
76
    }
77
 
78
    if (i==1 && t.tv_sec == 2+(int)a) {
79
      i = 2;
80
      kern_printf("before internal_sem_post %d\n",(int)a);
81
      internal_sem_post(&s);
82
      kern_printf("after internal_sem_post %d\n",(int)a);
83
      return 0;
84
    }
85
 
86
 
87
  } while (1);
88
}
89
 
90
int main(int argc, char **argv)
91
{
92
//  struct timespec t;
93
//  int i;
94
  NRT_TASK_MODEL m;
95
  PID p2,p3;
96
 
97
  nrt_task_default_model(m);
98
  nrt_task_def_group(m,1);
99
 
100
  nrt_task_def_arg(m,(void *)1);
101
  p2 = task_create("pippo1", pippo, &m, NULL);
102
  if (p2 == NIL)
103
  { kern_printf("Can't create pippo1 task...\n"); return 1; }
104
 
105
  nrt_task_def_arg(m,(void *)2);
106
  p3 = task_create("pippo2", pippo, &m, NULL);
107
  if (p3 == NIL)
108
  { kern_printf("Can't create pippo2 task...\n"); return 1; }
109
 
110
  internal_sem_init(&s,1);
111
 
112
  group_activate(1);
113
 
114
  return 0;
115
}