[rtems-central commit] spec: Clarify thread exitted extension

Sebastian Huber sebh at rtems.org
Tue Jul 25 05:14:32 UTC 2023


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sat Jul 22 11:46:08 2023 +0200

spec: Clarify thread exitted extension

---

 spec/rtems/userext/req/thread-exitted.yml | 15 +++++++
 spec/rtems/userext/val/userext.yml        | 67 ++++++++++++++++++++++++++++++-
 spec/testsuites/userext.yml               |  2 +
 3 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/spec/rtems/userext/req/thread-exitted.yml b/spec/rtems/userext/req/thread-exitted.yml
new file mode 100644
index 00000000..1cb5bb93
--- /dev/null
+++ b/spec/rtems/userext/req/thread-exitted.yml
@@ -0,0 +1,15 @@
+SPDX-License-Identifier: CC-BY-SA-4.0
+copyrights:
+- Copyright (C) 2023 embedded brains GmbH & Co. KG
+enabled-by: true
+links:
+- role: requirement-refinement
+  uid: ../if/group
+functional-type: function
+rationale: null
+references: []
+requirement-type: functional
+text: |
+  When a ${/glossary/task-entry:/term} returns, the thread exitted
+  ${/glossary/userextensions:/term} shall be invoked.
+type: requirement
diff --git a/spec/rtems/userext/val/userext.yml b/spec/rtems/userext/val/userext.yml
index 6dd9d194..4a872912 100644
--- a/spec/rtems/userext/val/userext.yml
+++ b/spec/rtems/userext/val/userext.yml
@@ -180,6 +180,8 @@ test-actions:
     code: |
       CheckForward( THREAD_EXITTED, 1, 1, thread, NULL );
     links:
+    - role: validation
+      uid: ../req/thread-exitted
     - role: validation
       uid: ../req/thread-exitted-iterate-remove
     - role: validation
@@ -334,6 +336,51 @@ test-actions:
     - role: validation
       uid: ../req/thread-terminate-iterate-remove
   links: []
+- action-brief: |
+    Create five dynamic extensions.  Let an idle thread return from its entry.
+    Delete three dynamic extension during the thread exitted invocation.  Clean
+    up the used resources.
+  action-code: |
+    rtems_tcb *thread;
+    rtems_id   id;
+
+    /* ID of idle thread of processor 0 */
+    id = 0x09010001;
+    thread = GetThread( id );
+    SendEvents( id, RTEMS_EVENT_0 );
+    SetPriority( id, PRIO_HIGH );
+  checks:
+  - brief: |
+      Check that the thread exitted extensions were invoked in the right order.
+    code: |
+      CheckForward( THREAD_EXITTED, 1, 1, thread, NULL );
+    links:
+    - role: validation
+      uid: ../req/thread-exitted
+    - role: validation
+      uid: ../req/thread-exitted-iterate-remove
+    - role: validation
+      uid: ../req/thread-exitted-order
+  - brief: |
+      Check that the other extensions were not invoked.
+    code: |
+      CheckForward( THREAD_BEGIN, 0, 0, NULL, NULL );
+      CheckForward( THREAD_CREATE, 0, 0, NULL, NULL );
+      CheckReverse( THREAD_DELETE, 0, 0, NULL, NULL );
+      CheckForward( THREAD_RESTART, 0, 0, NULL, NULL );
+      CheckForward( THREAD_START, 0, 0, NULL, NULL );
+      CheckForward( THREAD_SWITCH, 0, 0, NULL, NULL );
+      CheckReverse( THREAD_TERMINATE, 0, 0, NULL, NULL );
+    links: []
+  - brief: |
+      Check that the thread exitted extension of the extension set deleted
+      before its turn in the invocation was not invoked.
+    code: |
+      CheckDeletedNotInvoked( THREAD_EXITTED );
+    links:
+    - role: validation
+      uid: ../req/thread-exitted-iterate-remove
+  links: []
 test-brief: |
   Tests the thread user extensions.
 test-context: []
@@ -485,7 +532,13 @@ test-support: |
 
     if ( index == 6 && ( kind == THREAD_EXITTED || kind == THREAD_RESTART ) ) {
       StopTestCase();
-      rtems_task_exit();
+
+      if ( GetExecuting()->is_idle ) {
+        SetSelfPriority( RTEMS_MAXIMUM_PRIORITY );
+        _CPU_Thread_Idle_body( 0 );
+      } else {
+        rtems_task_exit();
+      }
     }
 
     if ( index == 0 && kind == THREAD_TERMINATE ) {
@@ -707,6 +760,18 @@ test-support: |
     (void) StartTestCase( THREAD_TERMINATE );
     rtems_task_exit();
   }
+
+  void *IdleBody( uintptr_t arg )
+  {
+    rtems_event_set events;
+
+    do {
+      events = PollAnyEvents();
+    } while ( events == 0 );
+
+    (void) StartTestCase( THREAD_EXITTED );
+    return (void *) arg;
+  }
 test-target: testsuites/validation/tc-userext.c
 test-teardown:
   brief: null
diff --git a/spec/testsuites/userext.yml b/spec/testsuites/userext.yml
index b449486d..6b8e706c 100644
--- a/spec/testsuites/userext.yml
+++ b/spec/testsuites/userext.yml
@@ -34,6 +34,8 @@ test-code: |
       .thread_terminate = ThreadTerminateExtension1 \
     }
 
+  #define CONFIGURE_IDLE_TASK_BODY IdleBody
+
   #include "ts-default.h"
 test-description: null
 test-includes: []



More information about the vc mailing list