summaryrefslogtreecommitdiffstats
path: root/spec/rtems/sem/val/uni.yml
blob: a824ca2037b7a0ac6f611f91ab0948d9c6b32d2f (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
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: []
test-actions:
- action-brief: |
    Create a worker thread and two MrsP mutexes.  Obtain the Mrsp mutexes and
    check that a task yield works (owner is not sticky).  We need two mutexes
    since the uniprocessor schedulers do not increment the stick level in the
    scheduler unblock operation.
  action-code: |
    rtems_status_code   sc;
    rtems_id            worker_id;

    sc = rtems_semaphore_create(
      rtems_build_name( 'M', 'T', 'X', '1' ),
      1,
      RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY |
        RTEMS_MULTIPROCESSOR_RESOURCE_SHARING,
      PRIO_NORMAL,
      &ctx->mutex_id
    );
    T_rsc_success( sc );

    sc = rtems_semaphore_create(
      rtems_build_name( 'M', 'T', 'X', '2' ),
      1,
      RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY |
        RTEMS_MULTIPROCESSOR_RESOURCE_SHARING,
      PRIO_NORMAL,
      &ctx->mutex_2_id
    );
    T_rsc_success( sc );

    ctx->counter = 0;

    worker_id = CreateTask( "WORK", PRIO_NORMAL );
    StartTask( worker_id, ObtainReleaseMrsPTask, ctx );
  checks:
  - brief: |
      Yield and let the worker obtain the MrsP mutexes.
    code: |
      Yield();
      T_eq_u32( ctx->counter, 1 );
    links:
    - role: validation
      uid: ../req/mrsp-uniprocessor-scheduler
  - brief: |
      Yield and let the worker release the MrsP mutexes.
    code: |
      Yield();
      T_eq_u32( ctx->counter, 2 );
    links: []
  - brief: |
      Clean up all used resources.
    code: |
      DeleteTask( worker_id );
      DeleteMutex( ctx->mutex_2_id );
      DeleteMutex( ctx->mutex_id );
    links: []
  links: []
test-brief: |
  Tests uniprocessor-specific semaphore behaviour.
test-context:
- brief: |
    This member contains the mutex identifier.
  description: null
  member: |
    rtems_id mutex_id
- brief: |
    This member contains the second mutex identifier.
  description: null
  member: |
    rtems_id mutex_2_id
- brief: |
    This member contains a progress counter.
  description: null
  member: |
    uint32_t counter
test-context-support: null
test-description: null
test-header: null
test-includes:
- rtems.h
test-local-includes:
- tx-support.h
test-setup:
  brief: null
  code: |
    SetSelfPriority( PRIO_NORMAL );
  description: null
test-stop: null
test-support: |
  typedef ${.:/test-context-type} Context;

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

    ctx = (Context *) arg;
    ObtainMutex( ctx->mutex_id );
    ObtainMutex( ctx->mutex_2_id );
    ctx->counter = 1;
    Yield();
    ReleaseMutex( ctx->mutex_2_id );
    ReleaseMutex( ctx->mutex_id );
    ctx->counter = 2;
    (void) ReceiveAnyEvents();
  }
test-target: testsuites/validation/tc-sem-uni.c
test-teardown:
  brief: null
  code: |
    RestoreRunnerPriority();
  description: null
type: test-case