summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2022-09-09 16:01:20 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2022-09-09 16:01:20 +0200
commit1d1ca36e675d58d9b1394497bcac7aa2b7cb2b94 (patch)
tree95ef97328d7306370b827e796b9e3908229b4609
parentmodules: Update rtems and rtems-docs (diff)
downloadrtems-central-1d1ca36e675d58d9b1394497bcac7aa2b7cb2b94.tar.bz2
spec: Add deadlock detection special case
-rw-r--r--spec/score/tq/req/deadlock-no-owner.yml18
-rw-r--r--spec/score/tq/val/tq.yml82
2 files changed, 100 insertions, 0 deletions
diff --git a/spec/score/tq/req/deadlock-no-owner.yml b/spec/score/tq/req/deadlock-no-owner.yml
new file mode 100644
index 00000000..72e42013
--- /dev/null
+++ b/spec/score/tq/req/deadlock-no-owner.yml
@@ -0,0 +1,18 @@
+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: deadlock
+functional-type: function
+rationale: null
+references: []
+requirement-type: functional
+text: |
+ While the owner of the thread queue is enqueued on another thread queue
+ owned by a thread other than the calling thread, and so on, while the
+ owner of the last thread queue of this dependency chain is enqueued on a
+ thread queue which is not owned by a thread, the deadlock detection shall
+ return with no deadlock detected.
+type: requirement
diff --git a/spec/score/tq/val/tq.yml b/spec/score/tq/val/tq.yml
new file mode 100644
index 00000000..caf54b41
--- /dev/null
+++ b/spec/score/tq/val/tq.yml
@@ -0,0 +1,82 @@
+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: []
+test-actions:
+- action-brief: |
+ Use two worker threads to provoke a deadlock detection involving a thread
+ queue with no owner.
+ action-code: |
+ TQReset( &ctx->tq_ctx );
+ checks:
+ - brief: |
+ Let blocker A obtain mutex A.
+ code: |
+ TQSend( &ctx->tq_ctx, TQ_BLOCKER_A, TQ_EVENT_MUTEX_A_OBTAIN );
+ links: []
+ - brief: |
+ Let blocker A block on a counting semaphore.
+ code: |
+ TQSend( &ctx->tq_ctx, TQ_BLOCKER_A, TQ_EVENT_MUTEX_D_OBTAIN );
+ links: []
+ - brief: |
+ Let blocker B block on mutex A. The deadlock detection will stop since
+ blocker A blocks on the counting semaphore which has no owner.
+ code: |
+ TQSend( &ctx->tq_ctx, TQ_BLOCKER_B, TQ_EVENT_MUTEX_A_OBTAIN );
+ links:
+ - role: validation
+ uid: ../req/deadlock-no-owner
+ - brief: |
+ Clean up all used resources.
+ code: |
+ TQMutexRelease( &ctx->tq_ctx, TQ_MUTEX_D );
+ TQSend( &ctx->tq_ctx, TQ_BLOCKER_A, TQ_EVENT_MUTEX_A_RELEASE );
+ TQSend( &ctx->tq_ctx, TQ_BLOCKER_B, TQ_EVENT_MUTEX_A_RELEASE );
+ links: []
+ links: []
+test-brief: |
+ Tests special thread queue behaviour.
+test-context:
+- brief: |
+ This member contains the thread queue test context.
+ description: null
+ member: |
+ TQContext tq_ctx
+test-context-support: null
+test-description: null
+test-header: null
+test-includes: []
+test-local-includes:
+- tx-support.h
+- tx-thread-queue.h
+test-setup:
+ brief: null
+ code: |
+ rtems_status_code sc;
+
+ SetSelfPriority( PRIO_NORMAL );
+ TQInitialize( &ctx->tq_ctx );
+
+ /* Replace mutex D with a counting semaphore */
+ DeleteMutex( ctx->tq_ctx.mutex_id[ TQ_MUTEX_D ] );
+ sc = rtems_semaphore_create(
+ rtems_build_name( 'C', 'S', 'E', 'M' ),
+ 0,
+ RTEMS_COUNTING_SEMAPHORE | RTEMS_PRIORITY,
+ 0,
+ &ctx->tq_ctx.mutex_id[ TQ_MUTEX_D ]
+ );
+ T_rsc_success( sc );
+ description: null
+test-stop: null
+test-support: null
+test-target: testsuites/validation/tc-score-tq.c
+test-teardown:
+ brief: null
+ code: |
+ TQDestroy( &ctx->tq_ctx );
+ RestoreRunnerPriority();
+ description: null
+type: test-case