Subversion Repositories shark

Rev

Rev 1085 | 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
 ------------
21
 CVS :        $Id: ptest5.c,v 1.1.1.1 2002-09-02 09:37:47 pj Exp $
22
 
23
 File:        $File$
24
 Revision:    $Revision: 1.1.1.1 $
25
 Last update: $Date: 2002-09-02 09:37:47 $
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
#include <drivers/keyb.h>
65
 
66
 
67
 
68
void signal_handler(int signo, siginfo_t *info, void *extra)
69
{
70
  cprintf("SIGNAL HANDLER: pid=%d\n",exec_shadow);
71
}
72
 
73
void fine(KEY_EVT *e)
74
{
75
  sys_end();
76
}
77
 
78
 
79
int main(int argc, char **argv)
80
{
81
  struct sigaction sig_act;
82
 
83
    KEY_EVT emerg;
84
    //keyb_set_map(itaMap);
85
    emerg.ascii = 'x';
86
    emerg.scan = KEY_X;
87
    emerg.flag = ALTL_BIT;
88
    keyb_hook(emerg,fine);
89
 
90
  sig_act.sa_sigaction = (void *) signal_handler;
91
  sig_act.sa_flags = SA_SIGINFO;
92
  sigemptyset(&sig_act.sa_mask);
93
 
94
  sigaction(SIGALRM, &sig_act, NULL);
95
 
96
  cprintf("main: alarm(5), waiting t=2 sec\n");
97
  alarm(5);
98
 
99
  while (sys_gettime(NULL) < 2000000);
100
 
101
  cprintf("main: alarm(3) return %d, waiting t=6 sec\n",alarm(3));
102
 
103
  pause();
104
//  while (sys_gettime(NULL) < 6000000);
105
 
106
  cprintf("main: ending...\n");
107
 
108
  return 0;
109
}