From f279017882f0d976c069b9a2bc26fee2489d6ed2 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 23 Nov 2023 14:52:21 +0100 Subject: validation: Improve MrsP validation For uniprocessor configurations, the selection of RTEMS_MULTIPROCESSOR_RESOURCE_SHARING results in a priority ceiling mutex. Build the MrsP validation tests only if RTEMS_SMP is enabled. Update #3716. --- spec/build/testsuites/validation/objmrsp.yml | 16 ++++++++++++++ .../validation/validation-no-clock-0.yml | 5 ++--- testsuites/validation/tc-sem-obtain.c | 25 +++++++++++++--------- testsuites/validation/tc-sem-timeout.c | 19 ++++++++++++---- testsuites/validation/tr-mtx-seize-wait.c | 9 +++++++- testsuites/validation/tr-mtx-surrender.c | 9 +++++++- 6 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 spec/build/testsuites/validation/objmrsp.yml diff --git a/spec/build/testsuites/validation/objmrsp.yml b/spec/build/testsuites/validation/objmrsp.yml new file mode 100644 index 0000000000..6d2c283b72 --- /dev/null +++ b/spec/build/testsuites/validation/objmrsp.yml @@ -0,0 +1,16 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: objects +cflags: [] +copyrights: +- Copyright (C) 2023 embedded brains GmbH & Co. KG +cppflags: [] +cxxflags: [] +enabled-by: RTEMS_SMP +includes: [] +install: [] +links: [] +source: +- testsuites/validation/tr-tq-enqueue-mrsp.c +- testsuites/validation/tr-tq-surrender-mrsp.c +- testsuites/validation/tr-tq-timeout-mrsp.c +type: build diff --git a/spec/build/testsuites/validation/validation-no-clock-0.yml b/spec/build/testsuites/validation/validation-no-clock-0.yml index d2341cd171..2a7a48a3b3 100644 --- a/spec/build/testsuites/validation/validation-no-clock-0.yml +++ b/spec/build/testsuites/validation/validation-no-clock-0.yml @@ -14,6 +14,8 @@ links: uid: objnodebug - role: build-dependency uid: objpreinitarray +- role: build-dependency + uid: objmrsp source: - testsuites/validation/tc-acfg.c - testsuites/validation/tc-attr.c @@ -140,17 +142,14 @@ source: - testsuites/validation/tr-tq-enqueue-ceiling.c - testsuites/validation/tr-tq-enqueue-deadlock.c - testsuites/validation/tr-tq-enqueue-fifo.c -- testsuites/validation/tr-tq-enqueue-mrsp.c - testsuites/validation/tr-tq-enqueue-priority.c - testsuites/validation/tr-tq-enqueue-priority-inherit.c - testsuites/validation/tr-tq-flush-fifo.c - testsuites/validation/tr-tq-flush-priority.c - testsuites/validation/tr-tq-flush-priority-inherit.c - testsuites/validation/tr-tq-surrender.c -- testsuites/validation/tr-tq-surrender-mrsp.c - testsuites/validation/tr-tq-surrender-priority-inherit.c - testsuites/validation/tr-tq-timeout.c -- testsuites/validation/tr-tq-timeout-mrsp.c - testsuites/validation/tr-tq-timeout-priority-inherit.c - testsuites/validation/ts-validation-no-clock-0.c stlib: [] diff --git a/testsuites/validation/tc-sem-obtain.c b/testsuites/validation/tc-sem-obtain.c index 3370a57604..10c4475d8c 100644 --- a/testsuites/validation/tc-sem-obtain.c +++ b/testsuites/validation/tc-sem-obtain.c @@ -499,11 +499,15 @@ static void RtemsSemReqObtain_Post_Action_Check( * spec:/score/mtx/req/seize-try where an enqueue is sticky, a recursive * seize returns an error status, and a priority ceiling is used. */ + #if defined(RTEMS_SMP) ctx->tq_mtx_ctx.base.enqueue_variant = TQ_ENQUEUE_STICKY; ctx->tq_mtx_ctx.protocol = TQ_MTX_MRSP; ctx->tq_mtx_ctx.recursive = TQ_MTX_RECURSIVE_DEADLOCK; ctx->tq_mtx_ctx.priority_ceiling = PRIO_VERY_HIGH; ScoreMtxReqSeizeTry_Run( &ctx->tq_mtx_ctx ); + #else + T_unreachable(); + #endif break; } @@ -513,11 +517,15 @@ static void RtemsSemReqObtain_Post_Action_Check( * spec:/score/mtx/req/seize-wait where an enqueue is sticky, a recursive * seize returns an error status, and a priority ceiling is used. */ + #if defined(RTEMS_SMP) ctx->tq_mtx_ctx.base.enqueue_variant = TQ_ENQUEUE_STICKY; ctx->tq_mtx_ctx.protocol = TQ_MTX_MRSP; ctx->tq_mtx_ctx.recursive = TQ_MTX_RECURSIVE_DEADLOCK; ctx->tq_mtx_ctx.priority_ceiling = PRIO_VERY_HIGH; ScoreMtxReqSeizeWait_Run( &ctx->tq_mtx_ctx ); + #else + T_unreachable(); + #endif break; } @@ -580,6 +588,7 @@ static void RtemsSemReqObtain_Action( RtemsSemReqObtain_Context *ctx ) ); T_rsc_success( sc ); + #if defined(RTEMS_SMP) if ( ( ctx->attribute_set & RTEMS_MULTIPROCESSOR_RESOURCE_SHARING ) != 0 ) { rtems_task_priority prio; @@ -591,6 +600,7 @@ static void RtemsSemReqObtain_Action( RtemsSemReqObtain_Context *ctx ) ); T_rsc_success( sc ); } + #endif } static void RtemsSemReqObtain_Cleanup( RtemsSemReqObtain_Context *ctx ) @@ -606,33 +616,28 @@ RtemsSemReqObtain_Entries[] = { { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_SemSeizeWait }, { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_SemSeizeTry }, { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_MtxSeizeWait }, -#if defined(RTEMS_SMP) - { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_InvId }, -#else - { 1, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_NA }, -#endif { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_MtxSeizeTry }, { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_CeilingMtxSeizeWait }, { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_InheritMtxSeizeWait }, #if defined(RTEMS_SMP) { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_MrsPMtxSeizeWait }, #else - { 1, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_NA }, + { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_CeilingMtxSeizeWait }, #endif { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_CeilingMtxSeizeTry }, { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_InheritMtxSeizeTry }, #if defined(RTEMS_SMP) { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_MrsPMtxSeizeTry } #else - { 1, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_NA } + { 0, 0, 0, 0, 0, RtemsSemReqObtain_Post_Action_CeilingMtxSeizeTry } #endif }; static const uint8_t RtemsSemReqObtain_Map[] = { - 3, 2, 2, 0, 0, 0, 3, 2, 2, 0, 0, 0, 3, 2, 2, 0, 0, 0, 3, 2, 2, 0, 0, 0, 6, 4, - 4, 0, 0, 0, 6, 4, 4, 0, 0, 0, 1, 1, 1, 1, 1, 1, 10, 7, 7, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 11, 8, 8, 0, 0, 0, 1, 1, 1, 1, 1, 1, 12, 9, 9, 5, 5, 5 + 3, 2, 2, 0, 0, 0, 3, 2, 2, 0, 0, 0, 3, 2, 2, 0, 0, 0, 3, 2, 2, 0, 0, 0, 5, 4, + 4, 0, 0, 0, 5, 4, 4, 0, 0, 0, 1, 1, 1, 1, 1, 1, 9, 6, 6, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 10, 7, 7, 0, 0, 0, 1, 1, 1, 1, 1, 1, 11, 8, 8, 0, 0, 0 }; static size_t RtemsSemReqObtain_Scope( void *arg, char *buf, size_t n ) diff --git a/testsuites/validation/tc-sem-timeout.c b/testsuites/validation/tc-sem-timeout.c index cdef96181e..a150d067d2 100644 --- a/testsuites/validation/tc-sem-timeout.c +++ b/testsuites/validation/tc-sem-timeout.c @@ -55,7 +55,6 @@ #include #include -#include "tr-tq-timeout-mrsp.h" #include "tr-tq-timeout-priority-inherit.h" #include "tr-tq-timeout.h" #include "tx-support.h" @@ -169,6 +168,10 @@ static const char * const * const RtemsSemReqTimeout_PreDesc[] = { NULL }; +#if defined(RTEMS_SMP) +#include "tr-tq-timeout-mrsp.h" +#endif + static void RtemsSemReqTimeout_Pre_Class_Prepare( RtemsSemReqTimeout_Context *ctx, RtemsSemReqTimeout_Pre_Class state @@ -226,7 +229,11 @@ static void RtemsSemReqTimeout_Pre_Class_Prepare( */ ctx->attribute_set |= RTEMS_BINARY_SEMAPHORE | RTEMS_MULTIPROCESSOR_RESOURCE_SHARING; + #if defined(RTEMS_SMP) ctx->tq_ctx.enqueue_variant = TQ_ENQUEUE_STICKY; + #else + ctx->tq_ctx.enqueue_variant = TQ_ENQUEUE_BLOCKS; + #endif break; } @@ -285,8 +292,12 @@ static void RtemsSemReqTimeout_Post_Action_Check( * The semaphore obtain timeout actions shall be done as specified by * spec:/score/tq/req/timeout-mrsp. */ + #if defined(RTEMS_SMP) ctx->tq_ctx.wait = TQ_WAIT_TIMED; ScoreTqReqTimeoutMrsp_Run( &ctx->tq_ctx ); + #else + T_unreachable(); + #endif break; } @@ -374,10 +385,10 @@ RtemsSemReqTimeout_Entries[] = { { 0, 0, 0, RtemsSemReqTimeout_Post_Action_Timeout }, { 1, 0, 0, RtemsSemReqTimeout_Post_Action_NA }, { 0, 0, 0, RtemsSemReqTimeout_Post_Action_TimeoutPriorityInherit }, -#if !defined(RTEMS_SMP) - { 1, 0, 0, RtemsSemReqTimeout_Post_Action_NA } -#else +#if defined(RTEMS_SMP) { 0, 0, 0, RtemsSemReqTimeout_Post_Action_TimeoutMrsP } +#else + { 0, 0, 0, RtemsSemReqTimeout_Post_Action_Timeout } #endif }; diff --git a/testsuites/validation/tr-mtx-seize-wait.c b/testsuites/validation/tr-mtx-seize-wait.c index 829b5334b0..71385d440f 100644 --- a/testsuites/validation/tr-mtx-seize-wait.c +++ b/testsuites/validation/tr-mtx-seize-wait.c @@ -56,7 +56,6 @@ #include "tr-tq-enqueue-ceiling.h" #include "tr-tq-enqueue-deadlock.h" #include "tr-tq-enqueue-fifo.h" -#include "tr-tq-enqueue-mrsp.h" #include "tr-tq-enqueue-priority-inherit.h" #include "tr-tq-enqueue-priority.h" @@ -218,6 +217,10 @@ static const char * const * const ScoreMtxReqSeizeWait_PreDesc[] = { NULL }; +#if defined(RTEMS_SMP) +#include "tr-tq-enqueue-mrsp.h" +#endif + typedef ScoreMtxReqSeizeWait_Context Context; static Status_Control Status( const Context *ctx, Status_Control status ) @@ -728,7 +731,11 @@ static void ScoreMtxReqSeizeWait_Post_Enqueued_Check( * The calling thread shall be enqueued in priority order according to * the MrsP locking protocol. */ + #if defined(RTEMS_SMP) ScoreTqReqEnqueueMrsp_Run( &ctx->tq_ctx->base ); + #else + T_unreachable(); + #endif break; } diff --git a/testsuites/validation/tr-mtx-surrender.c b/testsuites/validation/tr-mtx-surrender.c index e02b7282bd..657a80f924 100644 --- a/testsuites/validation/tr-mtx-surrender.c +++ b/testsuites/validation/tr-mtx-surrender.c @@ -53,7 +53,6 @@ #endif #include "tr-mtx-surrender.h" -#include "tr-tq-surrender-mrsp.h" #include "tr-tq-surrender-priority-inherit.h" #include "tr-tq-surrender.h" @@ -252,6 +251,10 @@ static const char * const * const ScoreMtxReqSurrender_PreDesc[] = { NULL }; +#if defined(RTEMS_SMP) +#include "tr-tq-surrender-mrsp.h" +#endif + typedef ScoreMtxReqSurrender_Context Context; static Status_Control Status( const Context *ctx, Status_Control status ) @@ -810,8 +813,12 @@ static void ScoreMtxReqSurrender_Post_Surrender_Check( * The thread queue of the mutex shall be surrendered in priority order * with MrsP. */ + #if defined(RTEMS_SMP) T_eq_u32( ctx->counter, 1 ); ScoreTqReqSurrenderMrsp_Run( &ctx->tq_ctx->base ); + #else + T_unreachable(); + #endif break; } -- cgit v1.2.3