source: rtems/testsuites/rhealstone/rhilatency/ilatency.c @ 1d799ad

4.115
Last change on this file since 1d799ad was 1d799ad, checked in by Sebastian Huber <sebastian.huber@…>, on 06/03/14 at 08:24:55

rhealstone: Produce proper begin/end messages

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/* Copyright 2014 Daniel Ramirez (javamonn@gmail.com)
2 *
3 * This file's license is 2-clause BSD as in this distribution's LICENSE.2 file.
4 */
5
6/*
7 *  WARNING!!!!!!!!!
8 *
9 *  THIS TEST USES INTERNAL RTEMS VARIABLES!!!
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#define CONFIGURE_INIT
17#include <timesys.h>
18#include <rtems/score/schedulerpriorityimpl.h>
19#include <rtems/timerdrv.h>
20#include <coverhd.h>
21
22/* configuration information */
23#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
24#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
25#define CONFIGURE_MAXIMUM_TASKS              2
26#define CONFIGURE_TICKS_PER_TIMESLICE        0
27#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
28#define CONFIGURE_SCHEDULER_PRIORITY
29
30#include <rtems/confdefs.h>
31
32#include <bsp.h>
33
34#define _RTEMS_TMTEST27
35#include <tm27.h>
36
37const char rtems_test_name[] = "RHILATENCY";
38
39#define BENCHMARKS 50000
40
41rtems_task Task_1(
42  rtems_task_argument argument
43);
44
45uint32_t   Interrupt_nest;
46uint32_t   timer_overhead;
47uint32_t   Interrupt_enter_time;
48
49rtems_isr Isr_handler(
50  rtems_vector_number vector
51);
52
53rtems_task Init(
54  rtems_task_argument argument
55)
56{
57  rtems_status_code status;
58  rtems_id Task_id;
59
60  Print_Warning();
61
62  TEST_BEGIN();
63
64  if (
65    _Scheduler_Table[ 0 ].Operations.initialize
66      != _Scheduler_priority_Initialize
67  ) {
68    puts( "  Error ==> " );
69    puts( "Test only supported for deterministic priority scheduler\n" );
70    rtems_test_exit( 0 );
71  }
72
73#define LOW_PRIORITY (RTEMS_MAXIMUM_PRIORITY - 1u)
74  status = rtems_task_create(
75    rtems_build_name( 'T', 'A', '1', ' ' ),
76    LOW_PRIORITY,
77    RTEMS_MINIMUM_STACK_SIZE,
78    RTEMS_DEFAULT_MODES,
79    RTEMS_DEFAULT_ATTRIBUTES,
80    &Task_id
81  );
82  directive_failed( status, "rtems_task_create Task_1" );
83
84  status = rtems_task_start( Task_id, Task_1, 0 );
85  directive_failed( status, "rtems_task_start Task_1" );
86
87  benchmark_timer_initialize();
88  benchmark_timer_read();
89  benchmark_timer_initialize();
90  timer_overhead = benchmark_timer_read();
91
92  status = rtems_task_delete( RTEMS_SELF );
93  directive_failed( status, "rtems_task_delete of RTEMS_SELF" );
94}
95
96rtems_task Task_1(
97  rtems_task_argument argument
98)
99{
100  Install_tm27_vector( Isr_handler ) ;
101  Interrupt_nest = 0;
102
103  /* Benchmark code */
104  benchmark_timer_initialize();
105  /* goes to Isr_handler */
106  Cause_tm27_intr();
107
108  put_time(
109    "Rhealstone: Interrupt Latency",
110    Interrupt_enter_time,
111    1,                             /* Only Rhealstone that isn't an average */
112    timer_overhead,
113    0
114  );
115
116  TEST_END();
117  rtems_test_exit( 0 );
118}
119
120rtems_isr Isr_handler(
121  rtems_vector_number vector
122)
123{
124  /* See how long it took system to recognize interrupt */
125  Interrupt_enter_time = benchmark_timer_read();
126  Clear_tm27_intr();
127}
Note: See TracBrowser for help on using the repository browser.