Subversion Repositories shark

Rev

Rev 1086 | 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: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/**
20
 ------------
1449 giacomo 21
 CVS :        $Id: ptest5.c,v 1.2 2004-05-23 09:05:51 giacomo Exp $
1085 pj 22
 
23
 File:        $File$
1449 giacomo 24
 Revision:    $Revision: 1.2 $
25
 Last update: $Date: 2004-05-23 09:05:51 $
1085 pj 26
 ------------
27
 
28
 Posix test 5:
29
   an alarm test
30
 
31
 non standard function used:
32
   cprintf
33
   sys_gettime
34
   keyboard stuffs
35
   sys_end
36
 
37
**/
38
 
39
/*
40
 * Copyright (C) 2000 Paolo Gai
41
 *
42
 * This program is free software; you can redistribute it and/or modify
43
 * it under the terms of the GNU General Public License as published by
44
 * the Free Software Foundation; either version 2 of the License, or
45
 * (at your option) any later version.
46
 *
47
 * This program is distributed in the hope that it will be useful,
48
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
50
 * GNU General Public License for more details.
51
 *
52
 * You should have received a copy of the GNU General Public License
53
 * along with this program; if not, write to the Free Software
54
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
55
 *
56
 */
57
 
58
#include <sys/types.h>
59
#include <pthread.h>
60
#include <signal.h>
61
#include <unistd.h>
62
 
63
#include <kernel/kern.h>
64
 
65
void signal_handler(int signo, siginfo_t *info, void *extra)
66
{
67
  cprintf("SIGNAL HANDLER: pid=%d\n",exec_shadow);
68
}
69
 
70
int main(int argc, char **argv)
71
{
72
  struct sigaction sig_act;
73
 
74
  sig_act.sa_sigaction = (void *) signal_handler;
75
  sig_act.sa_flags = SA_SIGINFO;
76
  sigemptyset(&sig_act.sa_mask);
77
 
78
  sigaction(SIGALRM, &sig_act, NULL);
79
 
80
  cprintf("main: alarm(5), waiting t=2 sec\n");
81
  alarm(5);
82
 
83
  while (sys_gettime(NULL) < 2000000);
84
 
85
  cprintf("main: alarm(3) return %d, waiting t=6 sec\n",alarm(3));
86
 
87
  pause();
88
//  while (sys_gettime(NULL) < 6000000);
89
 
90
  cprintf("main: ending...\n");
91
 
92
  return 0;
93
}