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: testf.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 15 (F):
27
 
28
 This test verify the correctness of the PI module.
29
 
30
 
31
 the main task (NRT) lock a PI mutex.
32
 then 2 tasks arrives, with priority higher than the main
33
 
34
 the first try to lock the mutex, but it can't, so the main inherit
35
 his priority. The second simply prints a string.
36
 
37
 If all works, the string of the second task is printed after the end of
38
 the first task.
39
 
40
**/
41
 
42
/*
43
 * Copyright (C) 2000 Paolo Gai
44
 *
45
 * This program is free software; you can redistribute it and/or modify
46
 * it under the terms of the GNU General Public License as published by
47
 * the Free Software Foundation; either version 2 of the License, or
48
 * (at your option) any later version.
49
 *
50
 * This program is distributed in the hope that it will be useful,
51
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
52
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
53
 * GNU General Public License for more details.
54
 *
55
 * You should have received a copy of the GNU General Public License
56
 * along with this program; if not, write to the Free Software
57
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
58
 *
59
 */
60
 
61
#include "kernel/kern.h"
62
 
63
mutex_t        m1;
64
 
65
 
66
TASK pippo1(void *a)
67
{
68
//  int i=0;
69
//  struct timespec t;
70
//  int last = 0;
71
 
72
  kern_printf("pippo1 prima di mutex_lock\n");
73
  mutex_lock(&m1);
74
  kern_printf("pippo1 dopo mutex_lock\n");
75
 
76
  mutex_unlock(&m1);
77
  kern_printf("pippo1 dopo mutex_unlock\n");
78
  return 0;
79
}
80
 
81
TASK pippo2()
82
{
83
 kern_printf("pippo2 Dentro pippo2\n");
84
 return 0;
85
}
86
 
87
int main(int argc, char **argv)
88
{
89
//  struct timespec t;
90
//  int i;
91
  HARD_TASK_MODEL m;
92
  PID p2,p3;
93
 
94
  PI_mutexattr_t a;
95
 
96
  hard_task_default_model(m);
97
  hard_task_def_mit(m,50000);
98
  hard_task_def_wcet(m,10000);
99
  hard_task_def_group(m,1);
100
 
101
  hard_task_def_arg(m,(void *)1);
102
  p2 = task_create("pippo1", pippo1, &m, NULL);
103
  if (p2 == NIL)
104
  { kern_printf("Can't create pippo1 task...\n"); return 1; }
105
 
106
  hard_task_def_mit(m,100000);
107
  p3 = task_create("pippo2", pippo2, &m, NULL);
108
  if (p3 == NIL)
109
  { kern_printf("Can't create pippo2 task...\n"); return 1; }
110
 
111
  PI_mutexattr_default(a);
112
  mutex_init(&m1,&a);
113
 
114
  kern_printf("main prima di mutex_lock\n");
115
  mutex_lock(&m1);
116
  kern_printf("main dopo mutex_lock, exec=%d, exec_shadow=%d\n", exec, exec_shadow);
117
 
118
  group_activate(1);
119
 
120
  kern_printf("main dopo group_activate, exec=%d, exec_shadow=%d\n", exec, exec_shadow);
121
  mutex_unlock(&m1);
122
  kern_printf("main dopo mutex_unlock\n");
123
 
124
  mutex_destroy(&m1);
125
  kern_printf("main dopo mutex_destroy\n");
126
 
127
  return 0;
128
}