source: rtems/testsuites/sptests/spintrcritical06/init.c @ db862461

4.104.115
Last change on this file since db862461 was bbebcd2c, checked in by Joel Sherrill <joel.sherrill@…>, on 07/21/09 at 15:16:57

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: 4.3 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
16/* common parameters */
17#define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
18#define SEMAPHORE_OBTAIN_TIMEOUT 0
19
20#if defined(PRIORITY_NO_TIMEOUT_FORWARD)
21  #define TEST_NAME          "06"
22  #define TEST_STRING        "Priority/Restart Search Task (Forward)"
23
24  #define INIT_PRIORITY      2
25  #define BLOCKER_PRIORITY   1
26
27#elif defined(PRIORITY_NO_TIMEOUT_REVERSE)
28  #define TEST_NAME          "07"
29  #define TEST_STRING        "Priority/Restart Search Task (Backward)"
30  #define INIT_PRIORITY      126
31  #define BLOCKER_PRIORITY   127
32
33#else
34
35  #error "Test Mode not defined"
36#endif
37
38rtems_id Main_task;
39rtems_id Secondary_task_id;
40rtems_id Semaphore;
41volatile bool case_hit;
42
43Thread_blocking_operation_States getState(void)
44{
45  Objects_Locations  location;
46  Semaphore_Control *sem;
47
48  sem = (Semaphore_Control *)_Objects_Get(
49    &_Semaphore_Information, Semaphore, &location );
50  if ( location != OBJECTS_LOCAL ) {
51    puts( "Bad object lookup" );
52    rtems_test_exit(0);
53  }
54  _Thread_Unnest_dispatch();
55
56  return sem->Core_control.semaphore.Wait_queue.sync_state;
57}
58
59rtems_timer_service_routine test_release_from_isr(
60  rtems_id  timer,
61  void     *arg
62)
63{
64printk("r");
65  (void) rtems_task_restart( Secondary_task_id, 1 );
66}
67
68rtems_task Secondary_task(
69  rtems_task_argument arg
70)
71{
72  rtems_status_code     status;
73
74#if 0
75  if ( arg ) {
76    printk("f");
77    (void) rtems_semaphore_flush( Semaphore );
78  }
79#endif
80
81  #if 0 && defined(PRIORITY_NO_TIMEOUT_REVERSE)
82    status = rtems_task_resume( Main_task );
83    directive_failed( status, "rtems_task_resume" );
84  #endif
85
86    printk("O");
87  status = rtems_semaphore_obtain(
88    Semaphore,
89    RTEMS_DEFAULT_OPTIONS,
90    SEMAPHORE_OBTAIN_TIMEOUT
91  );
92  directive_failed( status, "rtems_semaphore_obtain" );
93}
94
95rtems_task Init(
96  rtems_task_argument ignored
97)
98{
99  rtems_status_code     status;
100  int                   resets;
101
102  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
103
104#if defined(PRIORITY_NO_TIMEOUT_REVERSE)
105  puts( "WARNING!!! TEST IS NOT COMPLETE!!!" );
106  puts( "WARNING!!! TEST IS NOT COMPLETE!!!" );
107  puts( "WARNING!!! TEST IS NOT COMPLETE!!!" );
108  puts( "WARNING!!! TEST IS NOT COMPLETE!!!" );
109#endif
110
111  puts( "Init - Trying to generate semaphore release from ISR while blocking" );
112  puts( "Init - Variation is: " TEST_STRING );
113  status = rtems_semaphore_create(
114    rtems_build_name( 'S', 'M', '1', ' ' ),
115    0,
116    SEMAPHORE_ATTRIBUTES,
117    RTEMS_NO_PRIORITY,
118    &Semaphore
119  );
120  directive_failed( status, "rtems_semaphore_create of SM1" );
121
122  Main_task = rtems_task_self();
123
124  status = rtems_task_create(
125    rtems_build_name( 'B', 'L', 'C', 'K' ),
126    1,
127    RTEMS_MINIMUM_STACK_SIZE,
128    RTEMS_NO_PREEMPT,
129    RTEMS_DEFAULT_ATTRIBUTES,
130    &Secondary_task_id
131  );
132  directive_failed( status, "rtems_task_create" );
133
134  status = rtems_task_start( Secondary_task_id, Secondary_task, 0 );
135  directive_failed( status, "rtems_task_start" );
136
137  interrupt_critical_section_test_support_initialize( test_release_from_isr );
138
139  for (resets=0 ; resets< 2 ;) {
140    if ( interrupt_critical_section_test_support_delay() )
141      resets++;
142    #if defined(PRIORITY_NO_TIMEOUT_REVERSE)
143      status = rtems_task_suspend( RTEMS_SELF );
144      directive_failed( status, "rtems_task_suspend" );
145    #endif
146
147printk("o");
148    status = rtems_semaphore_obtain(
149      Semaphore,
150      RTEMS_DEFAULT_OPTIONS,
151      SEMAPHORE_OBTAIN_TIMEOUT
152    );
153    fatal_directive_status(status, RTEMS_UNSATISFIED, "rtems_semaphore_obtain");
154  }
155
156  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
157  rtems_test_exit(0);
158}
159
160/* configuration information */
161
162#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
163#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
164
165#define CONFIGURE_MAXIMUM_TASKS       2
166#define CONFIGURE_MAXIMUM_TIMERS      1
167#define CONFIGURE_MAXIMUM_SEMAPHORES  1
168#define CONFIGURE_INIT_TASK_PRIORITY  INIT_PRIORITY
169#define CONFIGURE_INIT_TASK_MODE      RTEMS_PREEMPT
170#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
171
172#define CONFIGURE_INIT
173#include <rtems/confdefs.h>
174
175/* global variables */
Note: See TracBrowser for help on using the repository browser.