source: rtems/testsuites/sptests/spintrcritical08/init.c @ 03b900d

5
Last change on this file since 03b900d was 03b900d, checked in by Sebastian Huber <sebastian.huber@…>, on 02/18/16 at 07:36:26

score: Replace watchdog handler implementation

Use a red-black tree instead of delta chains.

Close #2344.
Update #2554.
Update #2555.
Close #2606.

  • Property mode set to 100644
File size: 3.1 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.org/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#include <rtems/score/watchdogimpl.h>
17#include <rtems/rtems/ratemonimpl.h>
18
19const char rtems_test_name[] = "SPINTRCRITICAL 8";
20
21/* forward declarations to avoid warnings */
22rtems_task Init(rtems_task_argument argument);
23
24static rtems_id Period;
25
26static volatile bool case_hit = false;
27
28static rtems_rate_monotonic_period_states getState(void)
29{
30  Objects_Locations       location;
31  Rate_monotonic_Control *period;
32
33  period = (Rate_monotonic_Control *)_Objects_Get(
34    &_Rate_monotonic_Information, Period, &location );
35  if ( location != OBJECTS_LOCAL ) {
36    puts( "Bad object lookup" );
37    rtems_test_exit(0);
38  }
39  _Thread_Unnest_dispatch();
40
41  return period->state;
42}
43
44static rtems_timer_service_routine test_release_from_isr(
45  rtems_id  timer,
46  void     *arg
47)
48{
49  Per_CPU_Control *cpu = _Per_CPU_Get();
50  Watchdog_Header *header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ];
51  Watchdog_Control *watchdog = (Watchdog_Control *) header->first;
52
53  if (
54    watchdog != NULL
55      && watchdog->expire == cpu->Watchdog.ticks
56      && watchdog->routine == _Rate_monotonic_Timeout
57  ) {
58    _Watchdog_Per_CPU_remove_relative( watchdog );
59
60    (*watchdog->routine)( watchdog );
61
62    if ( getState() == RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING ) {
63      case_hit = true;
64    }
65  }
66}
67
68static bool test_body( void *arg )
69{
70  rtems_status_code sc;
71
72  (void) arg;
73
74  sc = rtems_rate_monotonic_cancel( Period );
75  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
76
77  sc = rtems_rate_monotonic_period( Period, 1 );
78  rtems_test_assert( sc == RTEMS_SUCCESSFUL );
79
80  sc = rtems_rate_monotonic_period( Period, 1 );
81  rtems_test_assert( sc == RTEMS_SUCCESSFUL || sc == RTEMS_TIMEOUT );
82
83  return case_hit;
84}
85
86rtems_task Init(
87  rtems_task_argument ignored
88)
89{
90  rtems_status_code     sc;
91
92  TEST_BEGIN();
93
94  puts( "Init - Trying to generate period ending while blocking" );
95
96  puts( "Init - rtems_rate_monotonic_create - OK" );
97  sc = rtems_rate_monotonic_create(
98    rtems_build_name( 'P', 'E', 'R', '1' ),
99    &Period
100  );
101  directive_failed( sc, "rtems_rate_monotonic_create" );
102
103  interrupt_critical_section_test( test_body, NULL, test_release_from_isr );
104
105  if ( case_hit ) {
106    puts( "Init - It appears the case has been hit" );
107    TEST_END();
108  } else
109    puts( "Init - Case not hit - ran too long" );
110  rtems_test_exit(0);
111}
112
113/* configuration information */
114
115#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
116#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
117
118#define CONFIGURE_MAXIMUM_TASKS       2
119#define CONFIGURE_MAXIMUM_TIMERS      1
120#define CONFIGURE_MAXIMUM_PERIODS     1
121#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1
122#define CONFIGURE_MICROSECONDS_PER_TICK  1000
123#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
124
125#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
126
127#define CONFIGURE_INIT
128#include <rtems/confdefs.h>
129
130/* global variables */
Note: See TracBrowser for help on using the repository browser.