From f9e1437f5aa39bfb8baf066a6637aca3d897bd79 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 28 Sep 2021 16:11:23 +0200 Subject: validation: rtems_semaphore_release() --- testsuites/validation/tc-sem-release.c | 14 ++++++----- testsuites/validation/tr-sem-surrender.c | 42 +++++++++++++++++--------------- testsuites/validation/tr-sem-surrender.h | 8 +++--- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/testsuites/validation/tc-sem-release.c b/testsuites/validation/tc-sem-release.c index 33cecd4777..4796ceed40 100644 --- a/testsuites/validation/tc-sem-release.c +++ b/testsuites/validation/tc-sem-release.c @@ -359,8 +359,8 @@ static void RtemsSemReqRelease_Post_Action_Check( case RtemsSemReqRelease_Post_Action_MtxSurrender: { /* * 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. */ ctx->tq_ctx.enqueue_variant = TQ_ENQUEUE_BLOCKS; ctx->tq_ctx.get_owner = TQGetOwnerClassicSem; @@ -375,8 +375,9 @@ static void RtemsSemReqRelease_Post_Action_Check( case RtemsSemReqRelease_Post_Action_InheritMtxSurrender: { /* * 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. */ ctx->tq_ctx.enqueue_variant = TQ_ENQUEUE_BLOCKS; ctx->tq_ctx.get_owner = TQGetOwnerClassicSem; @@ -392,7 +393,7 @@ static void RtemsSemReqRelease_Post_Action_Check( /* * 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. */ ctx->tq_ctx.enqueue_variant = TQ_ENQUEUE_BLOCKS; ctx->tq_ctx.get_owner = TQGetOwnerClassicSem; @@ -408,7 +409,8 @@ static void RtemsSemReqRelease_Post_Action_Check( /* * 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. */ ctx->tq_ctx.enqueue_variant = TQ_ENQUEUE_STICKY; ctx->tq_ctx.get_owner = TQGetOwnerClassicSem; diff --git a/testsuites/validation/tr-sem-surrender.c b/testsuites/validation/tr-sem-surrender.c index 754b88f1e1..139b302547 100644 --- a/testsuites/validation/tr-sem-surrender.c +++ b/testsuites/validation/tr-sem-surrender.c @@ -53,6 +53,7 @@ #endif #include "tr-sem-surrender.h" +#include "tr-tq-surrender.h" #include @@ -70,7 +71,7 @@ typedef struct { uint16_t Pre_Discipline_NA : 1; uint16_t Pre_Count_NA : 1; uint16_t Post_Status : 2; - uint16_t Post_Dequeue : 2; + uint16_t Post_Surrender : 2; uint16_t Post_Count : 3; } ScoreSemReqSurrender_Entry; @@ -310,31 +311,30 @@ static void ScoreSemReqSurrender_Post_Status_Check( } } -static void ScoreSemReqSurrender_Post_Dequeue_Check( - ScoreSemReqSurrender_Context *ctx, - ScoreSemReqSurrender_Post_Dequeue state +static void ScoreSemReqSurrender_Post_Surrender_Check( + ScoreSemReqSurrender_Context *ctx, + ScoreSemReqSurrender_Post_Surrender state ) { switch ( state ) { - case ScoreSemReqSurrender_Post_Dequeue_FIFO: { + case ScoreSemReqSurrender_Post_Surrender_FIFO: { /* - * 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. */ - /* TODO */ + ScoreTqReqSurrender_Run( &ctx->tq_ctx->base ); break; } - case ScoreSemReqSurrender_Post_Dequeue_Priority: { + case ScoreSemReqSurrender_Post_Surrender_Priority: { /* - * 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. */ - /* TODO */ + ScoreTqReqSurrender_Run( &ctx->tq_ctx->base ); break; } - case ScoreSemReqSurrender_Post_Dequeue_NA: + case ScoreSemReqSurrender_Post_Surrender_NA: break; } } @@ -407,23 +407,24 @@ static void ScoreSemReqSurrender_Action( ScoreSemReqSurrender_Context *ctx ) ctx->status = TQSurrender( &ctx->tq_ctx->base ); ctx->count_after = TQSemGetCount( ctx->tq_ctx ); + TQSemSetCount( ctx->tq_ctx, 1 ); } static const ScoreSemReqSurrender_Entry ScoreSemReqSurrender_Entries[] = { { 0, 0, 0, 0, ScoreSemReqSurrender_Post_Status_Ok, - ScoreSemReqSurrender_Post_Dequeue_NA, ScoreSemReqSurrender_Post_Count_One }, + ScoreSemReqSurrender_Post_Surrender_NA, ScoreSemReqSurrender_Post_Count_One }, { 0, 0, 0, 0, ScoreSemReqSurrender_Post_Status_Ok, - ScoreSemReqSurrender_Post_Dequeue_FIFO, + ScoreSemReqSurrender_Post_Surrender_FIFO, ScoreSemReqSurrender_Post_Count_Zero }, { 0, 0, 0, 0, ScoreSemReqSurrender_Post_Status_Ok, - ScoreSemReqSurrender_Post_Dequeue_Priority, + ScoreSemReqSurrender_Post_Surrender_Priority, ScoreSemReqSurrender_Post_Count_Zero }, { 0, 0, 0, 0, ScoreSemReqSurrender_Post_Status_Ok, - ScoreSemReqSurrender_Post_Dequeue_NA, + ScoreSemReqSurrender_Post_Surrender_NA, ScoreSemReqSurrender_Post_Count_PlusOne }, { 0, 0, 0, 0, ScoreSemReqSurrender_Post_Status_MaxCountExceeded, - ScoreSemReqSurrender_Post_Dequeue_NA, ScoreSemReqSurrender_Post_Count_Nop } + ScoreSemReqSurrender_Post_Surrender_NA, ScoreSemReqSurrender_Post_Count_Nop } }; static const uint8_t @@ -518,7 +519,10 @@ static void ScoreSemReqSurrender_TestVariant( ScoreSemReqSurrender_Pre_Count_Prepare( ctx, ctx->Map.pcs[ 2 ] ); ScoreSemReqSurrender_Action( ctx ); ScoreSemReqSurrender_Post_Status_Check( ctx, ctx->Map.entry.Post_Status ); - ScoreSemReqSurrender_Post_Dequeue_Check( ctx, ctx->Map.entry.Post_Dequeue ); + ScoreSemReqSurrender_Post_Surrender_Check( + ctx, + ctx->Map.entry.Post_Surrender + ); ScoreSemReqSurrender_Post_Count_Check( ctx, ctx->Map.entry.Post_Count ); } diff --git a/testsuites/validation/tr-sem-surrender.h b/testsuites/validation/tr-sem-surrender.h index b1958c1cc1..06ab4c20c1 100644 --- a/testsuites/validation/tr-sem-surrender.h +++ b/testsuites/validation/tr-sem-surrender.h @@ -89,10 +89,10 @@ typedef enum { } ScoreSemReqSurrender_Post_Status; typedef enum { - ScoreSemReqSurrender_Post_Dequeue_FIFO, - ScoreSemReqSurrender_Post_Dequeue_Priority, - ScoreSemReqSurrender_Post_Dequeue_NA -} ScoreSemReqSurrender_Post_Dequeue; + ScoreSemReqSurrender_Post_Surrender_FIFO, + ScoreSemReqSurrender_Post_Surrender_Priority, + ScoreSemReqSurrender_Post_Surrender_NA +} ScoreSemReqSurrender_Post_Surrender; typedef enum { ScoreSemReqSurrender_Post_Count_Zero, -- cgit v1.2.3