source: rtems/testsuites/sptests/spintrcritical09/init.c @ bbebcd2c

4.104.11
Last change on this file since bbebcd2c was bbebcd2c, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 21, 2009 at 3:16:57 PM

2009-07-21 Joel Sherrill <joel.sherrill@…>

  • spintrcritical06/init.c: Add comment to indicate test is not finished and known to not hit the case.
  • Makefile.am, configure.ac: Add a couple more interrupt critical section tests.
  • spintrcritical08/.cvsignore, spintrcritical08/Makefile.am, spintrcritical08/init.c, spintrcritical08/spintrcritical08.doc, spintrcritical08/spintrcritical08.scn, spintrcritical09/.cvsignore, spintrcritical09/Makefile.am, spintrcritical09/init.c, spintrcritical09/spintrcritical09.doc, spintrcritical09/spintrcritical09.scn: New files.
  • Property mode set to 100644
File size: 2.8 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 __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1
13#include <tmacros.h>
14#include <intrcritical.h>
15
16rtems_id Main_task;
17rtems_id Flusher_id;
18rtems_id Semaphore;
19volatile bool case_hit;
20
21Thread_blocking_operation_States getState(void)
22{
23  Objects_Locations  location;
24  Semaphore_Control *sem;
25
26  sem = (Semaphore_Control *)_Objects_Get(
27    &_Semaphore_Information, Semaphore, &location ); 
28  if ( location != OBJECTS_LOCAL ) {
29    puts( "Bad object lookup" );
30    rtems_test_exit(0);
31  }
32  _Thread_Unnest_dispatch();
33
34  return sem->Core_control.semaphore.Wait_queue.sync_state;
35}
36
37rtems_timer_service_routine test_release_from_isr(
38  rtems_id  timer,
39  void     *arg
40)
41{
42  if ( getState() == THREAD_BLOCKING_OPERATION_TIMEOUT ) {
43    case_hit = true;
44  }
45}
46
47rtems_task Flusher(
48  rtems_task_argument ignored
49)
50{
51  rtems_status_code     sc;
52
53  while (1) {
54    sc = rtems_semaphore_flush( Semaphore );
55    directive_failed( sc, "rtems_semaphore_flush" );
56
57    sc = rtems_task_wake_after( 2 );
58    directive_failed( sc, "rtems_task_wake_after" );
59  }
60}
61
62rtems_task Init(
63  rtems_task_argument ignored
64)
65{
66  rtems_status_code     sc;
67
68  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION 09 ***" );
69
70  puts( "Init - Trying to generate timeout from ISR while blocking" );
71  sc = rtems_semaphore_create(
72    rtems_build_name( 'S', 'M', '1', ' ' ),
73    1,
74    RTEMS_DEFAULT_ATTRIBUTES,
75    RTEMS_NO_PRIORITY,
76    &Semaphore
77  );
78  directive_failed( sc, "rtems_semaphore_create of SM1" );
79
80  Main_task = rtems_task_self();
81
82  sc = rtems_task_create(
83    rtems_build_name( 'F', 'L', 'S', 'H' ),
84    1,
85    RTEMS_MINIMUM_STACK_SIZE,
86    RTEMS_DEFAULT_MODES,
87    RTEMS_DEFAULT_ATTRIBUTES,
88    &Flusher_id
89  );
90  directive_failed( sc, "rtems_task_create" );
91
92  sc = rtems_task_start( Flusher_id, Flusher, 0 );
93  directive_failed( sc, "rtems_task_start" );
94
95  interrupt_critical_section_test_support_initialize( test_release_from_isr );
96
97  case_hit = false;
98
99  while (!case_hit) {
100    interrupt_critical_section_test_support_delay();
101
102    (void) rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
103  }
104
105  puts( "Init - Case hit" );
106
107  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION 09 ***" );
108  rtems_test_exit(0);
109}
110
111/* configuration information */
112
113#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
114#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
115
116#define CONFIGURE_MAXIMUM_TASKS       2
117#define CONFIGURE_MAXIMUM_TIMERS      1
118#define CONFIGURE_MAXIMUM_SEMAPHORES  1
119#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
120#define CONFIGURE_MICROSECONDS_PER_TICK  500
121
122#define CONFIGURE_INIT
123#include <rtems/confdefs.h>
124
125/* global variables */
Note: See TracBrowser for help on using the repository browser.