source:
rtems/testsuites/psxtests/psxualarm/init.c
@
33c46f1
Last change on this file since 33c46f1 was 33c46f1, checked in by Joel Sherrill <joel.sherrill@…>, on 10/21/10 at 21:22:25 | |
---|---|
|
|
File size: 2.2 KB |
Line | |
---|---|
1 | /* |
2 | * COPYRIGHT (c) 1989-2009. |
3 | * On-Line Applications Research Corporation (OAR). |
4 | * |
5 | * The license and distribution terms for this file may be |
6 | * found in the file LICENSE in this distribution or at |
7 | * http://www.rtems.com/license/LICENSE. |
8 | * |
9 | * $Id$ |
10 | */ |
11 | |
12 | #define CONFIGURE_INIT |
13 | #include "system.h" |
14 | #include <signal.h> |
15 | #include <unistd.h> |
16 | #include <errno.h> |
17 | typedef void (*sighandler_t)(int); |
18 | sighandler_t signal(int signum, sighandler_t handler); |
19 | extern void _POSIX_signals_Abnormal_termination_handler( int signo ); |
20 | |
21 | volatile int Signal_occurred; |
22 | volatile int Signal_count; |
23 | |
24 | void Signal_handler( |
25 | int signo |
26 | ) |
27 | { |
28 | Signal_count++; |
29 | printf( |
30 | "Signal: %d caught by 0x%" PRIxpthread_t " (%d)\n", |
31 | signo, |
32 | pthread_self(), |
33 | Signal_count |
34 | ); |
35 | Signal_occurred = 1; |
36 | } |
37 | |
38 | rtems_timer_service_routine Signal_duringISR_TSR( |
39 | rtems_id ignored_id, |
40 | void *ignored_address |
41 | ) |
42 | { |
43 | int status; |
44 | status = kill( getpid(), SIGUSR1 ); |
45 | } |
46 | |
47 | |
48 | void *POSIX_Init( |
49 | void *argument |
50 | ) |
51 | { |
52 | int status; |
53 | useconds_t result; |
54 | struct sigaction act; |
55 | sigset_t mask; |
56 | |
57 | puts( "\n\n*** POSIX TEST UALARM ***" ); |
58 | |
59 | /* set the time of day, and print our buffer in multiple ways */ |
60 | |
61 | set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 ); |
62 | |
63 | /* get id of this thread */ |
64 | |
65 | Init_id = pthread_self(); |
66 | printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id ); |
67 | |
68 | Signal_occurred = 0; |
69 | Signal_count = 0; |
70 | |
71 | /* Validate ualarm is ignored if signal not caught */ |
72 | act.sa_handler = Signal_handler; |
73 | act.sa_flags = 0; |
74 | sigaction( SIGALRM, &act, NULL ); |
75 | puts( "Init: ualarm in 1 us" ); |
76 | sleep(3); |
77 | result = ualarm(1,0); |
78 | status = sleep(10); |
79 | |
80 | /* unblock Signal and see if it happened */ |
81 | status = sigemptyset( &mask ); |
82 | rtems_test_assert( !status ); |
83 | status = sigaddset( &mask, SIGALRM ); |
84 | rtems_test_assert( !status ); |
85 | puts( "Init: Unblock SIGALRM" ); |
86 | status = sigprocmask( SIG_UNBLOCK, &mask, NULL ); |
87 | rtems_test_assert( !status ); |
88 | status = sleep(10); |
89 | |
90 | /* stop ularm */ |
91 | puts( "Init: clear ualarm with 0,0" ); |
92 | result = ualarm(0,0); |
93 | status = sleep(10); |
94 | |
95 | puts( "*** END OF POSIX TEST UALARM ***" ); |
96 | rtems_test_exit(0); |
97 | |
98 | return NULL; /* just so the compiler thinks we returned something */ |
99 | } |
Note: See TracBrowser
for help on using the repository browser.