Rev 1449 | 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 | ------------ |
||
1550 | pj | 21 | CVS : $Id: ptest5.c,v 1.3 2005-01-08 14:36:11 pj Exp $ |
1085 | pj | 22 | |
23 | File: $File$ |
||
1550 | pj | 24 | Revision: $Revision: 1.3 $ |
25 | Last update: $Date: 2005-01-08 14:36:11 $ |
||
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 | |||
36 | **/ |
||
37 | |||
38 | /* |
||
39 | * Copyright (C) 2000 Paolo Gai |
||
40 | * |
||
41 | * This program is free software; you can redistribute it and/or modify |
||
42 | * it under the terms of the GNU General Public License as published by |
||
43 | * the Free Software Foundation; either version 2 of the License, or |
||
44 | * (at your option) any later version. |
||
45 | * |
||
46 | * This program is distributed in the hope that it will be useful, |
||
47 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
48 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
49 | * GNU General Public License for more details. |
||
50 | * |
||
51 | * You should have received a copy of the GNU General Public License |
||
52 | * along with this program; if not, write to the Free Software |
||
53 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
54 | * |
||
55 | */ |
||
56 | |||
57 | #include <sys/types.h> |
||
58 | #include <pthread.h> |
||
59 | #include <signal.h> |
||
60 | #include <unistd.h> |
||
61 | |||
62 | #include <kernel/kern.h> |
||
63 | |||
64 | void signal_handler(int signo, siginfo_t *info, void *extra) |
||
65 | { |
||
66 | cprintf("SIGNAL HANDLER: pid=%d\n",exec_shadow); |
||
67 | } |
||
68 | |||
69 | int main(int argc, char **argv) |
||
70 | { |
||
71 | struct sigaction sig_act; |
||
72 | |||
73 | sig_act.sa_sigaction = (void *) signal_handler; |
||
74 | sig_act.sa_flags = SA_SIGINFO; |
||
75 | sigemptyset(&sig_act.sa_mask); |
||
76 | |||
77 | sigaction(SIGALRM, &sig_act, NULL); |
||
78 | |||
79 | cprintf("main: alarm(5), waiting t=2 sec\n"); |
||
80 | alarm(5); |
||
81 | |||
82 | while (sys_gettime(NULL) < 2000000); |
||
83 | |||
84 | cprintf("main: alarm(3) return %d, waiting t=6 sec\n",alarm(3)); |
||
85 | |||
86 | pause(); |
||
87 | // while (sys_gettime(NULL) < 6000000); |
||
88 | |||
89 | cprintf("main: ending...\n"); |
||
90 | |||
91 | return 0; |
||
92 | } |