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

4.115
Last change on this file since ae75429 was ae75429, checked in by Sebastian Huber <sebastian.huber@…>, on 08/06/13 at 14:10:26

PR766: Delete RTEMS_VIOLATE_KERNEL_VISIBILITY

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
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
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <tmacros.h>
15#include <intrcritical.h>
16
17#include <rtems/rtems/semimpl.h>
18#include <rtems/score/watchdogimpl.h>
19
20static rtems_id Semaphore;
21static bool case_hit;
22
23static Thread_blocking_operation_States getState(void)
24{
25  Objects_Locations  location;
26  Semaphore_Control *sem;
27
28  sem = (Semaphore_Control *)_Objects_Get(
29    &_Semaphore_Information, Semaphore, &location );
30  if ( location != OBJECTS_LOCAL ) {
31    puts( "Bad object lookup" );
32    rtems_test_exit(0);
33  }
34  _Thread_Unnest_dispatch();
35
36  return sem->Core_control.semaphore.Wait_queue.sync_state;
37}
38
39static rtems_timer_service_routine test_release_from_isr(
40  rtems_id  timer,
41  void     *arg
42)
43{
44  Chain_Control *chain = &_Watchdog_Ticks_chain;
45
46  if ( !_Chain_Is_empty( chain ) ) {
47    Watchdog_Control *watchdog = _Watchdog_First( chain );
48
49    if (
50      watchdog->delta_interval == 0
51        && watchdog->routine == _Thread_queue_Timeout
52    ) {
53      Watchdog_States state = _Watchdog_Remove( watchdog );
54
55      rtems_test_assert( state == WATCHDOG_ACTIVE );
56      (*watchdog->routine)( watchdog->id, watchdog->user_data );
57
58      if ( getState() == THREAD_BLOCKING_OPERATION_TIMEOUT ) {
59        case_hit = true;
60      }
61    }
62  }
63}
64
65static rtems_task Init(
66  rtems_task_argument ignored
67)
68{
69  rtems_status_code     sc;
70  int                   resets;
71
72  puts( "\n\n*** TEST INTERRUPT CRITICAL SECTION 09 ***" );
73
74  puts( "Init - Test may not be able to detect case is hit reliably" );
75  puts( "Init - Trying to generate timeout from ISR while blocking" );
76  sc = rtems_semaphore_create(
77    rtems_build_name( 'S', 'M', '1', ' ' ),
78    0,
79    RTEMS_DEFAULT_ATTRIBUTES,
80    RTEMS_NO_PRIORITY,
81    &Semaphore
82  );
83  directive_failed( sc, "rtems_semaphore_create of SM1" );
84
85  interrupt_critical_section_test_support_initialize( test_release_from_isr );
86
87  case_hit = false;
88
89  for (resets=0 ; resets< 2 ;) {
90    if ( interrupt_critical_section_test_support_delay() )
91      resets++;
92
93    (void) rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 1 );
94  }
95
96  if ( case_hit ) {
97    puts( "Init - It appears the case has been hit" );
98    puts( "*** END OF TEST INTERRUPT CRITICAL SECTION 09 ***" );
99  } else
100    puts( "Init - Case not hit - ran too long" );
101
102  rtems_test_exit(0);
103}
104
105/* configuration information */
106
107#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
108#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
109
110#define CONFIGURE_MAXIMUM_TASKS       1
111#define CONFIGURE_MAXIMUM_TIMERS      1
112#define CONFIGURE_MAXIMUM_SEMAPHORES  1
113#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
114#define CONFIGURE_MICROSECONDS_PER_TICK  1000
115
116#define CONFIGURE_INIT
117#include <rtems/confdefs.h>
118
119/* global variables */
Note: See TracBrowser for help on using the repository browser.