source: rtems/testsuites/sptests/sp38/init.c @ b84f1fdc

4.104.115
Last change on this file since b84f1fdc was b84f1fdc, checked in by Joel Sherrill <joel.sherrill@…>, on 05/10/09 at 14:39:46

2009-05-10 Joel Sherrill <joel.sherrill@…>

  • sp04/system.h, sp04/task1.c, sp04/tswitch.c, sp07/init.c, sp12/init.c, sp13/putbuff.c, sp13/system.h, sp13/task1.c, sp15/init.c, sp16/system.h, sp19/fptask.c, sp25/system.h, sp26/task1.c, sp27/init.c, sp28/init.c, sp29/init.c, sp31/task1.c, sp33/init.c, sp34/changepri.c, sp35/priinv.c, sp37/init.c, sp38/init.c, sp39/init.c, sp41/init.c, sp42/init.c, sp43/init.c, sp44/init.c, sp45/init.c, sp46/init.c, sp47/init.c, sp48/init.c, spfatal03/testcase.h, spfatal05/testcase.h, spfatal06/testcase.h, spfatal_support/system.h, spobjgetnext/init.c, spsize/getint.c, spsize/size.c: Fix warnings.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  Classic API Signal to Task from ISR
3 *
4 *  COPYRIGHT (c) 1989-2009.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#define CONFIGURE_INIT
15#include "system.h"
16
17volatile bool signal_sent;
18volatile bool signal_processed;
19
20rtems_id main_task;
21void signal_handler(rtems_signal_set signals);
22rtems_timer_service_routine test_signal_from_isr(
23  rtems_id  timer,
24  void     *arg
25);
26
27void signal_handler(
28  rtems_signal_set signals
29)
30{
31  signal_processed = TRUE;
32}
33
34rtems_timer_service_routine test_signal_from_isr(
35  rtems_id  timer,
36  void     *arg
37)
38{
39  rtems_status_code     status;
40
41  status = rtems_signal_send( main_task, 0x0a0b0c0d );
42  directive_failed_with_level( status, "rtems_signal_send", 1 );
43
44  signal_sent = TRUE;
45}
46
47rtems_task Init(
48  rtems_task_argument argument
49)
50{
51  rtems_status_code     status;
52  rtems_id              timer;
53  rtems_interval        start;
54  rtems_interval        now;
55
56  puts( "\n\n*** TEST 38 ***" );
57
58  main_task = rtems_task_self();
59
60  /*
61   *  Timer used in multiple ways
62   */
63  status = rtems_timer_create( 1, &timer );
64  directive_failed( status, "rtems_timer_create" );
65
66  /*
67   *  Get starting time
68   */
69  status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start );
70  directive_failed( status, "rtems_clock_get start" );
71
72  status = rtems_signal_catch( signal_handler, RTEMS_DEFAULT_MODES );
73  directive_failed( status, "rtems_signal_catch" );
74  puts( "rtems_signal_catch - handler installed" );
75
76  /*
77   * Test Signal from ISR
78   */
79  signal_sent = FALSE;
80
81  status = rtems_timer_fire_after( timer, 10, test_signal_from_isr, NULL );
82  directive_failed( status, "timer_fire_after failed" );
83
84  while (1) {
85    status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &now );
86    directive_failed( status, "rtems_clock_get now" );
87    if ( (now-start) > 100 ) {
88      puts( "Signal from ISR did not get processed\n" );
89      rtems_test_exit( 0 );
90    }
91    if ( signal_processed )
92      break;
93  }
94
95  puts( "Signal sent from ISR has been processed" );
96  puts( "*** END OF TEST 38 ***" );
97  rtems_test_exit( 0 );
98}
Note: See TracBrowser for help on using the repository browser.