source: rtems/testsuites/sptests/spintrcritical16/init.c @ 3c8eda7

4.115
Last change on this file since 3c8eda7 was 3c8eda7, checked in by Joel Sherrill <joel.sherrill@…>, on 05/12/12 at 16:01:26

sptests - Eliminate missing prototype warnings

  • Property mode set to 100644
File size: 3.1 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
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
15#include <tmacros.h>
16#include <intrcritical.h>
17
18/* forward declarations to avoid warnings */
19rtems_task Init(rtems_task_argument argument);
20rtems_timer_service_routine test_release_from_isr(rtems_id  timer, void *arg);
21Thread_blocking_operation_States getState(void);
22
23#define TEST_NAME          "16"
24
25Thread_Control *Main_TCB;
26rtems_id        Main_task;
27rtems_id        Semaphore;
28volatile bool   case_hit;
29
30Thread_blocking_operation_States getState(void)
31{
32  Objects_Locations  location;
33  Semaphore_Control *sem;
34
35  sem = (Semaphore_Control *)_Objects_Get(
36    &_Semaphore_Information, Semaphore, &location );
37  if ( location != OBJECTS_LOCAL ) {
38    puts( "Bad object lookup" );
39    rtems_test_exit(0);
40  }
41  _Thread_Unnest_dispatch();
42
43  return sem->Core_control.semaphore.Wait_queue.sync_state;
44}
45
46rtems_timer_service_routine test_release_from_isr(
47  rtems_id  timer,
48  void     *arg
49)
50{
51  if ( getState() == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED ) {
52    case_hit = true;
53    (void) rtems_semaphore_release( Semaphore );
54  }
55  _Thread_queue_Process_timeout( Main_TCB );
56}
57
58rtems_task Init(
59  rtems_task_argument ignored
60)
61{
62  rtems_status_code     sc;
63  int                   resets;
64
65  puts(
66    "\n\n*** TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***\n"
67    "Init - Trying to generate timeout of a thread that had its blocking\n"
68    "Init -   request satisfied while blocking but before time timeout"
69  );
70
71  puts( "Init - rtems_semaphore_create - OK" );
72  sc = rtems_semaphore_create(
73    rtems_build_name( 'S', 'M', '1', ' ' ),
74    0,
75    RTEMS_DEFAULT_ATTRIBUTES,
76    RTEMS_NO_PRIORITY,
77    &Semaphore
78  );
79  directive_failed( sc, "rtems_semaphore_create of SM1" );
80
81  Main_task = rtems_task_self();
82  Main_TCB  = _Thread_Executing;
83
84  interrupt_critical_section_test_support_initialize( test_release_from_isr );
85
86  case_hit = false;
87
88  for (resets=0 ; !case_hit && resets<10 ;) {
89    if ( interrupt_critical_section_test_support_delay() )
90      resets++;
91
92    sc = rtems_semaphore_obtain( Semaphore, RTEMS_DEFAULT_OPTIONS, 2 );
93    if ( sc == RTEMS_SUCCESSFUL )
94      break;
95    fatal_directive_status( sc, RTEMS_TIMEOUT, "rtems_semaphore_obtain" );
96  }
97
98  if ( case_hit ) {
99    puts( "Init - Case hit" );
100    puts( "*** END OF TEST INTERRUPT CRITICAL SECTION " TEST_NAME " ***" );
101  } else
102    puts( "Init - Case not hit - ran too long" );
103
104
105  rtems_test_exit(0);
106}
107
108/* configuration information */
109
110#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
111#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
112
113#define CONFIGURE_MAXIMUM_TASKS          1
114#define CONFIGURE_MAXIMUM_TIMERS         1
115#define CONFIGURE_MAXIMUM_SEMAPHORES     1
116#define CONFIGURE_MICROSECONDS_PER_TICK  1000
117#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
118
119#define CONFIGURE_INIT
120#include <rtems/confdefs.h>
121
122/* global variables */
Note: See TracBrowser for help on using the repository browser.