summaryrefslogtreecommitdiffstats
path: root/spec/rtems/task/val/perf.yml
blob: 39871a4349f9d354be419a95b6fed95ba5461fd2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021 embedded brains GmbH & Co. KG
enabled-by: true
links:
- role: validation
  uid: ../req/perf-runtime
params:
  sample-count: 100
test-brief: |
  This test case provides a context to run ${../if/group:/name} performance
  tests.
test-cleanup: null
test-context:
- brief: |
    This member provides a worker identifier.
  description: null
  member: |
    rtems_id worker_id
- brief: |
    This member provides a second worker identifier.
  description: null
  member: |
    rtems_id worker_2_id
- brief: |
    This member provides a status code.
  description: null
  member: |
    rtems_status_code status
test-context-support: null
test-description: null
test-includes:
- rtems.h
test-local-includes:
- ts-config.h
- tx-support.h
test-prepare: null
test-setup:
  brief: |
    Set the runner priority.
  code: |
    SetSelfPriority( PRIO_NORMAL );
  description: null
test-stop: null
test-support: |
  #define EVENT_RESTART RTEMS_EVENT_0

  #define EVENT_SET_END RTEMS_EVENT_1

  #define EVENT_BUSY RTEMS_EVENT_2

  typedef ${.:/test-context-type} Context;

  RTEMS_ALIGNED( RTEMS_TASK_STORAGE_ALIGNMENT ) static char task_storage[
    RTEMS_TASK_STORAGE_SIZE(
      TEST_MAXIMUM_TLS_SIZE + TEST_MINIMUM_STACK_SIZE,
      RTEMS_DEFAULT_ATTRIBUTES
    )
  ];

  static const rtems_task_config config = {
    .name = OBJECT_NAME,
    .initial_priority = PRIO_NORMAL,
    .storage_area = task_storage,
    .storage_size = sizeof( task_storage ),
    .maximum_thread_local_storage_size = 0,
    .initial_modes = RTEMS_DEFAULT_MODES,
    .attributes = RTEMS_DEFAULT_ATTRIBUTES
  };

  static void Send( const Context *ctx, rtems_event_set events )
  {
    SendEvents( ctx->worker_id, events );
  }

  static void Worker( rtems_task_argument arg )
  {
    Context *ctx;

    ctx = (Context *) arg;
    ctx->end = T_tick();

    while ( true ) {
      rtems_event_set events;
      T_ticks         ticks;

      events = ReceiveAnyEvents();
      ticks = T_tick();

      if ( ( events & EVENT_RESTART ) != 0 ) {
        ctx->begin = T_tick();
        (void) rtems_task_restart( RTEMS_SELF, (rtems_task_argument) ctx );
      }

      if ( ( events & EVENT_SET_END ) != 0 ) {
        ctx->end = ticks;
      }

      if ( ( events & EVENT_BUSY ) != 0 ) {
        (void) _CPU_Thread_Idle_body( 0 );
      }
    }
  }
test-target: testsuites/validation/tc-task-performance.c
test-teardown:
  brief: |
    Restore the runner priority.
  code: |
    RestoreRunnerPriority();
  description: null
type: runtime-measurement-test