1 | /* |
---|
2 | * COPYRIGHT (c) 1989-1999. |
---|
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 | #include <pmacros.h> |
---|
13 | #include <errno.h> |
---|
14 | |
---|
15 | volatile int TSR_occurred; |
---|
16 | volatile int TSR_status; |
---|
17 | |
---|
18 | rtems_id timer_id; |
---|
19 | |
---|
20 | rtems_timer_service_routine Cancel_duringISR_TSR( |
---|
21 | rtems_id ignored_id, |
---|
22 | void *ignored_address |
---|
23 | ) |
---|
24 | { |
---|
25 | TSR_status = pthread_cancel( pthread_self() ); |
---|
26 | TSR_occurred = 1; |
---|
27 | } |
---|
28 | |
---|
29 | rtems_timer_service_routine SetState_duringISR_TSR( |
---|
30 | rtems_id ignored_id, |
---|
31 | void *ignored_address |
---|
32 | ) |
---|
33 | { |
---|
34 | int oldstate; |
---|
35 | |
---|
36 | TSR_status = pthread_setcancelstate( 0, &oldstate ); |
---|
37 | TSR_occurred = 1; |
---|
38 | } |
---|
39 | |
---|
40 | rtems_timer_service_routine SetType_duringISR_TSR( |
---|
41 | rtems_id ignored_id, |
---|
42 | void *ignored_address |
---|
43 | ) |
---|
44 | { |
---|
45 | int oldtype; |
---|
46 | |
---|
47 | TSR_status = pthread_setcanceltype( 0, &oldtype ); |
---|
48 | TSR_occurred = 1; |
---|
49 | } |
---|
50 | |
---|
51 | void doit( |
---|
52 | rtems_timer_service_routine (*TSR)(rtems_id, void *), |
---|
53 | const char *method |
---|
54 | ) |
---|
55 | { |
---|
56 | rtems_interval start; |
---|
57 | rtems_interval end; |
---|
58 | rtems_status_code status; |
---|
59 | |
---|
60 | printf( "Init: schedule %s from a TSR\n", method ); |
---|
61 | |
---|
62 | TSR_occurred = 0; |
---|
63 | TSR_status = 0; |
---|
64 | |
---|
65 | status = rtems_timer_fire_after( timer_id, 10, TSR, NULL ); |
---|
66 | assert( !status ); |
---|
67 | |
---|
68 | do { |
---|
69 | end = rtems_clock_get_ticks_since_boot(); |
---|
70 | } while ( !TSR_occurred && ((end - start) <= 800)); |
---|
71 | |
---|
72 | if ( !TSR_occurred ) { |
---|
73 | printf( "%s did not occur\n", method ); |
---|
74 | rtems_test_exit(0); |
---|
75 | } |
---|
76 | if ( TSR_status != EPROTO ) { |
---|
77 | printf( "%s returned %s\n", method, strerror(TSR_status) ); |
---|
78 | rtems_test_exit(0); |
---|
79 | } |
---|
80 | printf( "%s - from ISR returns EPROTO - OK\n", method ); |
---|
81 | |
---|
82 | } |
---|
83 | |
---|
84 | void *POSIX_Init( |
---|
85 | void *argument |
---|
86 | ) |
---|
87 | { |
---|
88 | rtems_status_code status; |
---|
89 | |
---|
90 | puts( "\n\n*** POSIX TEST CANCEL 01 ***" ); |
---|
91 | |
---|
92 | status = rtems_timer_create( |
---|
93 | rtems_build_name( 'T', 'M', '1', ' ' ), |
---|
94 | &timer_id |
---|
95 | ); |
---|
96 | assert( !status ); |
---|
97 | |
---|
98 | doit( Cancel_duringISR_TSR, "pthread_cancel" ); |
---|
99 | doit( SetState_duringISR_TSR, "pthread_setcancelstate" ); |
---|
100 | doit( SetType_duringISR_TSR, "pthread_setcanceltype" ); |
---|
101 | |
---|
102 | puts( "*** END OF POSIX TEST CANCEL 01 ***" ); |
---|
103 | rtems_test_exit(0); |
---|
104 | return NULL; /* just so the compiler thinks we returned something */ |
---|
105 | } |
---|
106 | |
---|
107 | /* configuration information */ |
---|
108 | |
---|
109 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
110 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
111 | |
---|
112 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
113 | |
---|
114 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 1 |
---|
115 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
116 | |
---|
117 | #define CONFIGURE_INIT |
---|
118 | #include <rtems/confdefs.h> |
---|