Subversion Repositories shark

Rev

Rev 1085 | 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: test5.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 5:
27
 
28
 this test is a simple main() function with one other task
29
 
30
 This test has to be compiled with init1.c, that introduce 2 RR levels
31
 with a timeslice of 300us (!)
32
 
33
 This test can be useful to test functions like
34
 
35
 sigemptyset
36
 sigaddset
37
 hartik_deliver_pending_signals
38
 sys_end
39
 task_sigmask
40
 sigaction
41
 sigqueue
42
 task_signal
43
 
44
 
45
**/
46
 
47
/*
48
 * Copyright (C) 2000 Paolo Gai
49
 *
50
 * This program is free software; you can redistribute it and/or modify
51
 * it under the terms of the GNU General Public License as published by
52
 * the Free Software Foundation; either version 2 of the License, or
53
 * (at your option) any later version.
54
 *
55
 * This program is distributed in the hope that it will be useful,
56
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
58
 * GNU General Public License for more details.
59
 *
60
 * You should have received a copy of the GNU General Public License
61
 * along with this program; if not, write to the Free Software
62
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
63
 *
64
 */
65
 
66
#include "kernel/kern.h"
67
 
68
 
69
TASK pippo()
70
{
71
  struct timespec t;
72
 
73
  do {
74
    kern_cli();
75
    ll_gettime(TIME_EXACT, &t);
76
    kern_sti();
77
 
78
  } while (t.tv_nsec <= 20000000L);
79
  cli(); kern_printf("pippo"); sti();
80
  return 0;
81
}
82
 
83
void catchit(int signo, siginfo_t *info, void *extra)
84
{
85
  kern_printf("\nÛ exec_shadow= %d signo=%d code=%d value=%d p=%d Û\n",
86
            exec_shadow,
87
            info->si_signo, info->si_code,
88
            info->si_value.sival_int, info->si_task);
89
}
90
 
91
 
92
void catchit2(int signo)
93
{
94
  kern_printf("\nSignal %d: AAARRRRRRGGGGHHHH!!!!\n",signo);
95
}
96
 
97
int main(int argc, char **argv)
98
{
99
  struct timespec t;
100
  NRT_TASK_MODEL m;
101
  PID p2;
102
 
103
  sigset_t newmask;
104
  sigset_t oldmask;
105
  struct sigaction action;
106
  union sigval sval;
107
 
108
 
109
  /* Set the signal action */
110
  action.sa_flags = SA_SIGINFO;
111
  action.sa_sigaction = catchit;
112
  action.sa_handler = 0;
113
  action.sa_mask = 0;
114
 
115
  if (sigaction(SIGUSR1, &action, NULL) == -1) {
116
    perror("Errore");
117
    return -1;
118
  }
119
 
120
  action.sa_flags = 0;
121
  action.sa_handler = catchit2;
122
// action.sa_sigaction = SIG_DFL;
123
 
124
  if (sigaction(SIGILL, &action, NULL) == -1) {
125
    perror("Errore");
126
    return -1;
127
  }
128
 
129
  /* create another task */
130
  nrt_task_default_model(m);
131
  nrt_task_def_level(m,1);
132
  nrt_task_def_group(m,1);
133
 
134
  p2 = task_create("pippo", pippo, &m, NULL);
135
  if (p2 == NIL)
136
  { kern_printf("Can't create pippo task...\n"); return 1; }
137
 
138
  group_activate(1);
139
 
140
  /* block the signal for the main task */
141
  sigemptyset(&newmask);
142
  sigaddset(&newmask,SIGUSR1);
143
  task_sigmask(SIG_BLOCK, &newmask, &oldmask);
144
 
145
  sval.sival_int = 123;
146
  sigqueue(0,SIGUSR1,sval);
147
  sval.sival_int = 999;
148
  sigqueue(0,SIGUSR1,sval);
149
 
150
  cli();kern_printf("\n()()()()\n"); sti();
151
 
152
  task_signal(0 /* main */, SIGILL);
153
 
154
  NULL_TIMESPEC(&t);
155
  do {
156
    kern_cli();
157
    ll_gettime(TIME_EXACT, &t);
158
    kern_sti();
159
 
160
  } while (t.tv_nsec <= 50000000L);
161
 
162
  cli();kern_printf("\n()*********()\n"); sti();
163
 
164
  return 0;
165
}