blob: 02e21c216f838d814d4d85001566a1ae245168d8 (
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
112
113
114
115
116
117
118
119
120
121
122
123
|
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
copyrights:
- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
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 mutex identifier.
description: null
member: |
rtems_id mutex_id
- brief: |
This member provides a worker identifier.
description: null
member: |
rtems_id worker_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:
- tx-support.h
test-prepare: null
test-setup:
brief: |
Create a mutex and a worker task.
code: |
SetSelfPriority( PRIO_NORMAL );
ctx->mutex_id = CreateMutex();
ctx->worker_id = CreateTask( "WORK", PRIO_HIGH );
StartTask( ctx->worker_id, Worker, ctx );
description: null
test-stop: null
test-support: |
#define EVENT_END RTEMS_EVENT_0
#define EVENT_OBTAIN RTEMS_EVENT_1
#define EVENT_OBTAIN_END RTEMS_EVENT_2
#define EVENT_RELEASE RTEMS_EVENT_3
#define EVENT_RELEASE_END RTEMS_EVENT_4
typedef ${.:/test-context-type} Context;
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;
while ( true ) {
rtems_event_set events;
rtems_status_code sc;
T_ticks ticks;
sc = rtems_event_receive(
RTEMS_ALL_EVENTS,
RTEMS_EVENT_ANY | RTEMS_WAIT,
RTEMS_NO_TIMEOUT,
&events
);
ticks = T_tick();
T_quiet_rsc_success( sc );
if ( ( events & EVENT_END ) != 0 ) {
ctx->end = ticks;
}
if ( ( events & EVENT_OBTAIN ) != 0 ) {
sc = rtems_semaphore_obtain(
ctx->mutex_id,
RTEMS_WAIT,
RTEMS_NO_TIMEOUT
);
ticks = T_tick();
T_quiet_rsc_success( sc );
if ( ( events & EVENT_OBTAIN_END ) != 0 ) {
ctx->end = ticks;
}
}
if ( ( events & EVENT_RELEASE ) != 0 ) {
sc = rtems_semaphore_release( ctx->mutex_id );
ticks = T_tick();
T_quiet_rsc_success( sc );
if ( ( events & EVENT_RELEASE_END ) != 0 ) {
ctx->end = ticks;
}
}
}
}
test-target: testsuites/validation/tc-sem-performance.c
test-teardown:
brief: |
Delete the worker task and the mutex.
code: |
DeleteTask( ctx->worker_id );
DeleteMutex( ctx->mutex_id );
RestoreRunnerPriority();
description: null
type: runtime-measurement-test
|