source: rtems/testsuites/sptests/spintrcritical01/init.c @ 937a22a7

4.104.115
Last change on this file since 937a22a7 was 937a22a7, checked in by Joel Sherrill <joel.sherrill@…>, on 07/10/09 at 20:28:10

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

  • Makefile.am, configure.ac: Add new infrastructure which is more reliable about generating cases which hit interrupt critical sections. Remove sp41 since it used its own mechanism.
  • spintrcritical01/.cvsignore, spintrcritical01/Makefile.am, spintrcritical01/init.c, spintrcritical01/spintrcritical01.doc, spintrcritical01/spintrcritical01.scn, spintrcritical02/.cvsignore, spintrcritical02/Makefile.am, spintrcritical02/spintrcritical02.doc, spintrcritical02/spintrcritical02.scn, spintrcritical03/.cvsignore, spintrcritical03/Makefile.am, spintrcritical03/spintrcritical03.doc, spintrcritical03/spintrcritical03.scn, spintrcritical04/.cvsignore, spintrcritical04/Makefile.am, spintrcritical04/spintrcritical04.doc, spintrcritical04/spintrcritical04.scn, spintrcritical05/.cvsignore, spintrcritical05/Makefile.am, spintrcritical05/spintrcritical05.doc, spintrcritical05/spintrcritical05.scn: New files.
  • sp41/.cvsignore, sp41/Makefile.am, sp41/init.c, sp41/sp41.scn, sp41/system.h: Removed.
  • Property mode set to 100644
File size: 3.7 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#if defined(FIFO_NO_TIMEOUT)
17  #define TEST_NAME                "01"
18  #define TEST_STRING              "FIFO/Without Timeout"
19  #define SEMAPHORE_OBTAIN_TIMEOUT 0
20  #define SEMAPHORE_ATTRIBUTES     RTEMS_DEFAULT_ATTRIBUTES
21
22#elif defined(FIFO_WITH_TIMEOUT)
23  #define TEST_NAME                "02"
24  #define TEST_STRING              "FIFO/With Timeout"
25  #define SEMAPHORE_OBTAIN_TIMEOUT 10
26  #define SEMAPHORE_ATTRIBUTES     RTEMS_DEFAULT_ATTRIBUTES
27
28#elif defined(PRIORITY_NO_TIMEOUT)
29  #define TEST_NAME                "03"
30  #define TEST_STRING              "Priority/Without Timeout"
31  #define SEMAPHORE_OBTAIN_TIMEOUT 0
32  #define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
33
34#elif defined(PRIORITY_WITH_TIMEOUT)
35  #define TEST_NAME                "04"
36  #define TEST_STRING              "Priority/With Timeout"
37  #define SEMAPHORE_OBTAIN_TIMEOUT 10
38  #define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
39
40#elif defined(PRIORITY_NO_TIMEOUT_REVERSE)
41  #define TEST_NAME                "05"
42  #define TEST_STRING              "Priority/Without Timeout (Reverse)"
43  #define SEMAPHORE_OBTAIN_TIMEOUT 0
44  #define SEMAPHORE_ATTRIBUTES     RTEMS_PRIORITY
45
46#else
47
48  #error "Test Mode not defined"
49#endif
50
51rtems_id Main_task;
52rtems_id Semaphore;
53volatile bool case_hit;
54
55Thread_blocking_operation_States getState(void)
56{
57  Objects_Locations  location;
58  Semaphore_Control *sem;
59
60  sem = (Semaphore_Control *)_Objects_Get(
61    &_Semaphore_Information, Semaphore, &location );
62  if ( location != OBJECTS_LOCAL ) {
63    puts( "Bad object lookup" );
64    rtems_test_exit(0);
65  }
66  _Thread_Unnest_dispatch();
67
68  return sem->Core_control.semaphore.Wait_queue.sync_state;
69}
70
71rtems_timer_service_routine test_release_from_isr(
72  rtems_id  timer,
73  void     *arg
74)
75{
76  rtems_status_code     status;
77
78  if ( getState() == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
79    case_hit = true;
80  }
81  status = rtems_semaphore_release( Semaphore );
82}
83
84
85
86rtems_task Init(
87  rtems_task_argument ignored
88)
89{
90  rtems_status_code     status;
91
92  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
93
94  puts( "Init - Trying to generate semaphore release from ISR while blocking" );
95  puts( "Init - Variation is: " TEST_STRING );
96  status = rtems_semaphore_create(
97    rtems_build_name( 'S', 'M', '1', ' ' ),
98    1,
99    SEMAPHORE_ATTRIBUTES,
100    RTEMS_NO_PRIORITY,
101    &Semaphore
102  );
103  directive_failed( status, "rtems_semaphore_create of SM1" );
104
105  Main_task = rtems_task_self();
106
107  interrupt_critical_section_test_support_initialize( test_release_from_isr );
108
109  case_hit = false;
110
111  while (!case_hit) {
112    interrupt_critical_section_test_support_delay();
113
114    status = rtems_semaphore_obtain(
115      Semaphore,
116      RTEMS_DEFAULT_OPTIONS,
117      SEMAPHORE_OBTAIN_TIMEOUT
118    );
119    directive_failed( status, "rtems_semaphore_obtain" );
120  }
121
122  puts( "Init - Case hit" );
123
124  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
125  rtems_test_exit(0);
126}
127
128/* configuration information */
129
130#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
131#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
132
133#define CONFIGURE_MAXIMUM_TASKS       1
134#define CONFIGURE_MAXIMUM_TIMERS      1
135#define CONFIGURE_MAXIMUM_SEMAPHORES  1
136#if defined(PRIORITY_NO_TIMEOUT_REVERSE)
137  #define CONFIGURE_INIT_TASK_PRIORITY   250
138#endif
139#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
140
141#define CONFIGURE_INIT
142#include <rtems/confdefs.h>
143
144/* global variables */
Note: See TracBrowser for help on using the repository browser.