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.
This commit is contained in:
Sebastian Huber
2023-11-23 14:52:21 +01:00
parent 72c11fa91a
commit f279017882
6 changed files with 64 additions and 19 deletions

View File

@@ -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

View File

@@ -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: []

View File

@@ -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 )

View File

@@ -55,7 +55,6 @@
#include <rtems.h>
#include <string.h>
#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
};

View File

@@ -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;
}

View File

@@ -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;
}