[rtems-central commit] spec: Specify thread free of FPU owner

Sebastian Huber sebh at rtems.org
Thu Jul 7 08:02:37 UTC 2022


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Jul  5 10:09:21 2022 +0200

spec: Specify thread free of FPU owner

---

 spec/score/thread/req/free-fpu-owner.yml | 17 ++++++++
 spec/score/thread/val/thread.yml         | 66 ++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)

diff --git a/spec/score/thread/req/free-fpu-owner.yml b/spec/score/thread/req/free-fpu-owner.yml
new file mode 100644
index 00000000..6b818177
--- /dev/null
+++ b/spec/score/thread/req/free-fpu-owner.yml
@@ -0,0 +1,17 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2022 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: true
+links:
+- role: requirement-refinement
+  uid: ../if/group
+functional-type: function
+rationale: null
+references: []
+requirement-type: functional
+text: |
+  While a thread least recently used the
+  ${/glossary/floatingpointcoprocessor:/term}, when the thread resources are
+  freed, the thread-specific resources used by the
+  ${/glossary/floatingpointcoprocessor:/term} shall be freed.
+type: requirement
diff --git a/spec/score/thread/val/thread.yml b/spec/score/thread/val/thread.yml
index 48d4311a..ca735df8 100644
--- a/spec/score/thread/val/thread.yml
+++ b/spec/score/thread/val/thread.yml
@@ -78,6 +78,43 @@ test-actions:
   links:
   - role: validation
     uid: ../req/cancel-killer
+- action-brief: |
+    Delete a thread which least recently used the
+    ${/glossary/floatingpointcoprocessor:/term}.
+  action-code: |
+    rtems_status_code sc;
+
+    SetSelfPriority( PRIO_NORMAL );
+    sc = rtems_task_create(
+      rtems_build_name( 'W', 'O', 'R', 'K'),
+      PRIO_HIGH,
+      TEST_MINIMUM_STACK_SIZE,
+      RTEMS_DEFAULT_MODES,
+      RTEMS_FLOATING_POINT,
+      &ctx->worker_id
+    );
+    T_rsc_success( sc );
+  checks:
+  - brief: |
+      Start the worker thread.  Let it use the
+      ${/glossary/floatingpointcoprocessor:/term}.
+    code: |
+      StartTask( ctx->worker_id, FloatingPointTask, ctx );
+    links: []
+  - brief: |
+      Delete the worker thread and free the thread resources.
+    code: |
+      DeleteTask( ctx->worker_id );
+      KillZombies();
+    links:
+    - role: validation
+      uid: ../req/free-fpu-owner
+  - brief: |
+      Clean up all used resources.
+    code: |
+      RestoreRunnerPriority();
+    links: []
+  links: []
 test-brief: |
   Tests general thread behaviour.
 test-context:
@@ -91,6 +128,11 @@ test-context:
   description: null
   member: |
     rtems_id killer_id
+- brief: |
+    This member contains a floating-point object.
+  description: null
+  member: |
+    volatile double fp_obj
 test-context-support: null
 test-description: null
 test-header: null
@@ -99,6 +141,7 @@ test-includes:
 - rtems/score/statesimpl.h
 - rtems/score/threadimpl.h
 test-local-includes:
+- ts-config.h
 - tx-support.h
 test-setup: null
 test-stop: null
@@ -122,6 +165,29 @@ test-support: |
     SuspendSelf();
   }
 
+  static void GoBackToRunner( void *arg )
+  {
+    Context *ctx;
+
+    ctx = arg;
+    SetPriority( ctx->worker_id, PRIO_LOW );
+  }
+
+  static void FloatingPointTask( rtems_task_argument arg )
+  {
+    Context *ctx;
+
+    ctx = (Context *) arg;
+    ctx->fp_obj *= 1.23;
+
+    /*
+     * We use an interrupt to go back to the runner since on some
+     * architectures, the floating-point context is only saved during interrupt
+     * processing and not for synchronous thread switches.
+     */
+    CallWithinISR( GoBackToRunner, ctx );
+  }
+
   static void KillerTask( rtems_task_argument arg )
   {
     Context *ctx;



More information about the vc mailing list