source: rtems/testsuites/sptests/spintrcritical09/init.c @ 2d730043

4.104.115
Last change on this file since 2d730043 was 2d730043, checked in by Joel Sherrill <joel.sherrill@…>, on 07/22/09 at 21:46:56

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

  • spintrcritical09/init.c, spintrcritical09/spintrcritical09.scn: Make test work for case that it is documented to handle.
  • Property mode set to 100644
File size: 2.4 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 Semaphore;
18volatile bool case_hit;
19
20Thread_blocking_operation_States getState(void)
21{
22  Objects_Locations  location;
23  Semaphore_Control *sem;
24
25  sem = (Semaphore_Control *)_Objects_Get(
26    &_Semaphore_Information, Semaphore, &location );
27  if ( location != OBJECTS_LOCAL ) {
28    puts( "Bad object lookup" );
29    rtems_test_exit(0);
30  }
31  _Thread_Unnest_dispatch();
32
33  return sem->Core_control.semaphore.Wait_queue.sync_state;
34}
35
36rtems_timer_service_routine test_release_from_isr(
37  rtems_id  timer,
38  void     *arg
39)
40{
41  if ( getState() == THREAD_BLOCKING_OPERATION_TIMEOUT ) {
42    case_hit = true;
43  }
44}
45
46rtems_task Init(
47  rtems_task_argument ignored
48)
49{
50  rtems_status_code     sc;
51  int                   resets;
52
53  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION 09 ***" );
54
55  puts( "Init - Test may not be able to detect case is hit reliably" );
56  puts( "Init - Trying to generate timeout from ISR while blocking" );
57  sc = rtems_semaphore_create(
58    rtems_build_name( 'S', 'M', '1', ' ' ),
59    1,
60    RTEMS_DEFAULT_ATTRIBUTES,
61    RTEMS_NO_PRIORITY,
62    &Semaphore
63  );
64  directive_failed( sc, "rtems_semaphore_create of SM1" );
65
66  Main_task = rtems_task_self();
67
68  interrupt_critical_section_test_support_initialize( test_release_from_isr );
69
70  case_hit = false;
71
72  for (resets=0 ; resets< 2 ;) {
73    if ( interrupt_critical_section_test_support_delay() )
74      resets++;
75 
76    interrupt_critical_section_test_support_delay();
77
78    (void) rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
79  }
80
81  if (!case_hit)
82    rtems_test_exit(0);
83
84  puts( "Init - It appears we hit the case" );
85
86  puts( "*** END OF TEST INTERRUPT CRITICAL SECTION 09 ***" );
87  rtems_test_exit(0);
88}
89
90/* configuration information */
91
92#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
93#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
94
95#define CONFIGURE_MAXIMUM_TASKS       2
96#define CONFIGURE_MAXIMUM_TIMERS      1
97#define CONFIGURE_MAXIMUM_SEMAPHORES  1
98#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
99#define CONFIGURE_MICROSECONDS_PER_TICK  1000
100
101#define CONFIGURE_INIT
102#include <rtems/confdefs.h>
103
104/* global variables */
Note: See TracBrowser for help on using the repository browser.