[rtems-central commit] spec: Specify per-processor jobs order

Sebastian Huber sebh at rtems.org
Thu Aug 12 06:30:36 UTC 2021


Module:    rtems-central
Branch:    master
Commit:    5bf5cc67b599f1fc1bd0ce4ae150a654b3fde575
Changeset: http://git.rtems.org/rtems-central/commit/?id=5bf5cc67b599f1fc1bd0ce4ae150a654b3fde575

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Aug 11 14:50:06 2021 +0200

spec: Specify per-processor jobs order

---

 spec/score/smp/req/per-cpu-jobs-order.yml | 14 +++++
 spec/score/smp/val/per-cpu-jobs.yml       | 85 +++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+)

diff --git a/spec/score/smp/req/per-cpu-jobs-order.yml b/spec/score/smp/req/per-cpu-jobs-order.yml
new file mode 100644
index 0000000..30527bf
--- /dev/null
+++ b/spec/score/smp/req/per-cpu-jobs-order.yml
@@ -0,0 +1,14 @@
+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: RTEMS_SMP
+links:
+- role: requirement-refinement
+  uid: ../if/group
+functional-type: function
+rationale: null
+references: []
+requirement-type: functional
+text: |
+  Per-processor jobs shall be processed in ${/glossary/fifo:/term} order.
+type: requirement
diff --git a/spec/score/smp/val/per-cpu-jobs.yml b/spec/score/smp/val/per-cpu-jobs.yml
new file mode 100644
index 0000000..1168615
--- /dev/null
+++ b/spec/score/smp/val/per-cpu-jobs.yml
@@ -0,0 +1,85 @@
+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: RTEMS_SMP
+links: []
+test-actions:
+- action-brief: |
+    Issue two jobs on the current processor with interrupts disabled.  Wait for
+    completion of the second job.
+  action-code: |
+    rtems_interrupt_level level;
+    Per_CPU_Control      *cpu;
+
+    rtems_interrupt_local_disable(level);
+    cpu = _Per_CPU_Get();
+    _Per_CPU_Add_job( cpu, &job_0 );
+    _Per_CPU_Submit_job( cpu, &job_1 );
+    rtems_interrupt_local_enable(level);
+
+    _Per_CPU_Wait_for_job( cpu, &job_1 );
+  checks:
+  - brief: |
+      Check that the first job was processed firstly.
+    code: |
+      T_step_eq_int( ${step}, counter_0, 1 );
+    links:
+    - role: validation
+      uid: ../req/per-cpu-jobs-order
+  - brief: |
+      Check that the second job was processed secondly.
+    code: |
+      T_step_eq_int( ${step}, counter_1, 2 );
+    links:
+    - role: validation
+      uid: ../req/per-cpu-jobs-order
+  links: []
+test-brief: |
+  Tests the processing order of per-processor jobs.
+test-context: []
+test-context-support: null
+test-description: null
+test-header: []
+test-includes:
+- rtems.h
+- rtems/score/atomic.h
+- rtems/score/percpu.h
+test-local-includes: []
+test-setup: null
+test-stop: null
+test-support: |
+  static Atomic_Uint job_counter;
+
+  static void Increment( void *arg )
+  {
+    unsigned int *value;
+
+    value = (unsigned int *) arg;
+    *value =
+      _Atomic_Fetch_add_uint( &job_counter, 1, ATOMIC_ORDER_RELAXED ) + 1;
+  }
+
+  static unsigned int counter_0;
+
+  static const Per_CPU_Job_context job_context_0 = {
+    .handler = Increment,
+    .arg = &counter_0
+  };
+
+  Per_CPU_Job job_0 = {
+    .context = &job_context_0
+  };
+
+  static unsigned int counter_1;
+
+  static const Per_CPU_Job_context job_context_1 = {
+    .handler = Increment,
+    .arg = &counter_1
+  };
+
+  Per_CPU_Job job_1 = {
+    .context = &job_context_1,
+  };
+test-target: testsuites/validation/tc-score-smp-per-cpu-jobs.c
+test-teardown: null
+type: test-case



More information about the vc mailing list