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

4.104.115
Last change on this file since b1274bd9 was b1274bd9, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/30/09 at 03:33:25

Whitespace removal.

  • 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    (void) rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
77  }
78
79  if ( case_hit ) {
80    puts( "Init - It appears the case has been hit" );
81    puts( "*** END OF TEST INTERRUPT CRITICAL SECTION 09 ***" );
82  } else
83    puts( "Init - Case not hit - ran too long" );
84
85  rtems_test_exit(0);
86}
87
88/* configuration information */
89
90#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
91#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
92
93#define CONFIGURE_MAXIMUM_TASKS       2
94#define CONFIGURE_MAXIMUM_TIMERS      1
95#define CONFIGURE_MAXIMUM_SEMAPHORES  1
96#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
97#define CONFIGURE_MICROSECONDS_PER_TICK  1000
98
99#define CONFIGURE_INIT
100#include <rtems/confdefs.h>
101
102/* global variables */
Note: See TracBrowser for help on using the repository browser.