source: rtems/testsuites/rhealstone/rhtaskswitch/taskswitch.c @ 8fbe2e6

4.115
Last change on this file since 8fbe2e6 was 8fbe2e6, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/14 at 13:59:49

Use correct prototype of benchmark_timer_read()

This change starts with removing the effectively empty file
timerdrv.h. The prototypes for benchmark_timer_XXX() were in
btimer.h which was not universally used. Thus every use of
timerdrv.h had to be changed to btimer.h. Then the prototypes
for benchmark_timer_read() had to be adjusted to return
benchmark_timer_t rather than int or uint32_t.

I took this opportunity to also correct the file headers to
separate the copyright from the file description comments which
is needed to ensure the copyright isn't propagated into Doxygen
output.

  • Property mode set to 100644
File size: 3.3 KB
RevLine 
[19e9bf8]1/*
2 * Copyright (c) 2014 Daniel Ramirez. (javamonn@gmail.com)
3 *
4 * This file's license is 2-clause BSD as in this distribution's LICENSE file.
5 */
6
7#include <timesys.h>
[8fbe2e6]8#include <rtems/btimer.h>
[19e9bf8]9
10#define BENCHMARKS 50000
11
[1d799ad]12const char rtems_test_name[] = "RHTASKSWITCH";
13
[19e9bf8]14rtems_task Task01( rtems_task_argument ignored );
15rtems_task Task02( rtems_task_argument ignored );
16rtems_task Init( rtems_task_argument ignored );
17
18rtems_id           Task_id[2];
19rtems_name         Task_name[2];
20uint32_t           loop_overhead;
21uint32_t           dir_overhead;
22unsigned long      count1, count2;
23rtems_status_code  status;
24
25rtems_task Task02( rtems_task_argument ignored )
26{
27  uint32_t telapsed;
28
29  /* All overhead accounted for now, we can begin benchmark */
30  benchmark_timer_initialize();
31
32  for ( count1 = 0; count1 < BENCHMARKS - 1; count1++ ) {
33    rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
34  }
35
36  telapsed = benchmark_timer_read();
37  put_time(
38     "Rhealstone: Task switch",
39     telapsed,
40     ( BENCHMARKS * 2 ) - 1,   /* ( BENCHMARKS * 2 ) - 1 total benchmarks */
41     loop_overhead,            /* Overhead of loop */
42     dir_overhead              /* Overhead of rtems_task_wake_after directive */
43  );
44
[1d799ad]45  TEST_END();
[19e9bf8]46  rtems_test_exit( 0 );
47}
48
49rtems_task Task01( rtems_task_argument ignored )
50{
51  status = rtems_task_start( Task_id[1], Task02, 0 );
52  directive_failed( status, "rtems_task_start of TA02" );
53
54  /* Yield processor so second task can startup and run */
55  rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
56
57  for ( count2 = 0; count2 < BENCHMARKS; count2++ ) {
58    rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
59  }
60
61  /* Should never reach here */
62  rtems_test_assert( false );
63
64}
65
66rtems_task Init( rtems_task_argument ignored )
67{
[e8c7dbe7]68  Print_Warning();
69
[1d799ad]70  TEST_BEGIN();
[893aac16]71
[19e9bf8]72  Task_name[0] = rtems_build_name( 'T','A','0','1' );
73  status = rtems_task_create(
74    Task_name[0],
75    30,
76    RTEMS_MINIMUM_STACK_SIZE,
77    RTEMS_DEFAULT_MODES,
78    RTEMS_DEFAULT_ATTRIBUTES,
79    &Task_id[0]
80  );
81  directive_failed( status, "rtems_task_create of TA01" );
82
83  Task_name[1] = rtems_build_name( 'T','A','0','2' );
84  status = rtems_task_create(
85    Task_name[1],
86    30,
87    RTEMS_MINIMUM_STACK_SIZE,
88    RTEMS_DEFAULT_MODES,
89    RTEMS_DEFAULT_ATTRIBUTES,
90    &Task_id[1]
91  );
92  directive_failed( status, "rtems_task_create of TA02" );
93
94  /* find overhead of routine (no task switches) */
95  benchmark_timer_initialize();
96  for ( count1 = 0; count1 < BENCHMARKS - 1; count1++ ) {
97    /* rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ) */
98  }
99  for ( count2 = 0; count2 < BENCHMARKS; count2++ ) {
100    /* rtems_task_wake_after( RTEMS_YIELD_PROCESSOR ) */
101  }
102  loop_overhead = benchmark_timer_read();
103
104  /* find overhead of rtems_task_wake_after call (no task switches) */
105  benchmark_timer_initialize();
106  rtems_task_wake_after( RTEMS_YIELD_PROCESSOR );
107  dir_overhead = benchmark_timer_read();
108
109  status = rtems_task_start( Task_id[0], Task01, 0);
110  directive_failed( status, "rtems_task_start of TA01" );
111
112  status = rtems_task_delete( RTEMS_SELF);
113  directive_failed( status, "rtems_task_delete of INIT" );
114}
115
116/* configuration information */
117#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
118#define CONFIGURE_APPLICATION_NEEDS_TIMER_DRIVER
119#define CONFIGURE_TICKS_PER_TIMESLICE        0
120#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
121#define CONFIGURE_MAXIMUM_TASKS 3
122#define CONFIGURE_INIT
123#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.