[rtems-central commit] spec: Improve semaphore surrender

Sebastian Huber sebh at rtems.org
Wed Sep 29 12:18:08 UTC 2021


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Sep 28 16:09:40 2021 +0200

spec: Improve semaphore surrender

---

 spec/rtems/sem/req/release.yml   | 14 ++++++++------
 spec/score/sem/req/surrender.yml | 25 ++++++++++++++-----------
 2 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/spec/rtems/sem/req/release.yml b/spec/rtems/sem/req/release.yml
index 2f30836..9e43225 100644
--- a/spec/rtems/sem/req/release.yml
+++ b/spec/rtems/sem/req/release.yml
@@ -53,8 +53,8 @@ post-conditions:
       ${/score/mtx/req/surrender:/test-run}( &ctx->tq_mtx_ctx );
     text: |
       The calling task shall surrender the mutex as specified by
-      ${/score/mtx/req/surrender} where an enqueue blocks and a recursive seize
-      is allowed.
+      ${/score/mtx/req/surrender} where an enqueue blocks, a recursive seize is
+      allowed, the owner is checked, and no locking protocol is used.
   - name: InheritMtxSurrender
     test-code: |
       ctx->tq_ctx.enqueue_variant = TQ_ENQUEUE_BLOCKS;
@@ -66,8 +66,9 @@ post-conditions:
       ${/score/mtx/req/surrender:/test-run}( &ctx->tq_mtx_ctx );
     text: |
       The calling task shall surrender the mutex as specified by
-      ${/score/mtx/req/surrender} where an enqueue blocks and a recursive seize
-      is allowed.
+      ${/score/mtx/req/surrender} where an enqueue blocks, a recursive seize is
+      allowed, the owner is checked, and a priority inheritance protocol is
+      used.
   - name: CeilingMtxSurrender
     test-code: |
       ctx->tq_ctx.enqueue_variant = TQ_ENQUEUE_BLOCKS;
@@ -80,7 +81,7 @@ post-conditions:
     text: |
       The calling task shall surrender the mutex as specified by
       ${/score/mtx/req/surrender} where an enqueue blocks, a recursive seize is
-      allowed, and a priority ceiling is used.
+      allowed, the owner is checked, and a priority ceiling is used.
   - name: MrsPMtxSurrender
     test-code: |
       ctx->tq_ctx.enqueue_variant = TQ_ENQUEUE_STICKY;
@@ -93,7 +94,8 @@ post-conditions:
     text: |
       The calling task shall surrender the mutex as specified by
       ${/score/mtx/req/surrender} where an enqueue is sticky, a recursive seize
-      returns an error status, and a priority ceiling is used.
+      returns an error status, the owner is checked, and a priority ceiling is
+      used.
   test-epilogue: null
   test-prologue: |
     rtems_status_code sc;
diff --git a/spec/score/sem/req/surrender.yml b/spec/score/sem/req/surrender.yml
index fc76794..e2b83da 100644
--- a/spec/score/sem/req/surrender.yml
+++ b/spec/score/sem/req/surrender.yml
@@ -4,6 +4,8 @@ copyrights:
 enabled-by: true
 functional-type: action
 links:
+- role: function-implementation
+  uid: /score/tq/req/surrender
 - role: requirement-refinement
   uid: ../if/group
 post-conditions:
@@ -23,19 +25,18 @@ post-conditions:
       ${../../status/if/maximum-count-exceeded:/name}.
   test-epilogue: null
   test-prologue: null
-- name: Dequeue
+- name: Surrender
   states:
   - name: FIFO
     test-code: |
-      /* TODO */
+      ${../../tq/req/surrender:/test-run}( &ctx->tq_ctx->base );
     text: |
-      The first thread in FIFO order shall be dequeued from the thread queue.
+      The thread queue of the semaphore shall be surrendered in FIFO order.
   - name: Priority
     test-code: |
-      /* TODO */
+      ${../../tq/req/surrender:/test-run}( &ctx->tq_ctx->base );
     text: |
-      The first thread in priority order shall be dequeued from the thread
-      queue.
+      The thread queue of the semaphore shall be surrendered in priority order.
   test-epilogue: null
   test-prologue: null
 - name: Count
@@ -144,6 +145,7 @@ test-action: |
 
   ctx->status = TQSurrender( &ctx->tq_ctx->base );
   ctx->count_after = TQSemGetCount( ctx->tq_ctx );
+  TQSemSetCount( ctx->tq_ctx, 1 );
 test-brief: null
 test-cleanup: null
 test-context:
@@ -186,6 +188,7 @@ test-header:
 test-includes: []
 test-local-includes:
 - tr-sem-surrender.h
+- tr-tq-surrender.h
 test-prepare: null
 test-setup:
   brief: null
@@ -209,7 +212,7 @@ transition-map:
 - enabled-by: true
   post-conditions:
     Status: Ok
-    Dequeue: N/A
+    Surrender: N/A
     Count: One
   pre-conditions:
     Variant:
@@ -221,7 +224,7 @@ transition-map:
 - enabled-by: true
   post-conditions:
     Status: Ok
-    Dequeue:
+    Surrender:
     - specified-by: Discipline
     Count: Zero
   pre-conditions:
@@ -233,7 +236,7 @@ transition-map:
 - enabled-by: true
   post-conditions:
     Status: Ok
-    Dequeue: N/A
+    Surrender: N/A
     Count: PlusOne
   pre-conditions:
     Variant:
@@ -244,7 +247,7 @@ transition-map:
 - enabled-by: true
   post-conditions:
     Status: MaxCountExceeded
-    Dequeue: N/A
+    Surrender: N/A
     Count: Nop
   pre-conditions:
     Variant:
@@ -255,7 +258,7 @@ transition-map:
 - enabled-by: true
   post-conditions:
     Status: Ok
-    Dequeue:
+    Surrender:
     - specified-by: Discipline
     Count: Zero
   pre-conditions:



More information about the vc mailing list