[rtems commit] validation: Compatibility for other RTEMS versions

Sebastian Huber sebh at rtems.org
Tue Sep 26 07:30:16 UTC 2023


Module:    rtems
Branch:    master
Commit:    5a21b1d1331c9cfb5ffcb0903ff751981757285e
Changeset: http://git.rtems.org/rtems/commit/?id=5a21b1d1331c9cfb5ffcb0903ff751981757285e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Sep 26 08:34:17 2023 +0200

validation: Compatibility for other RTEMS versions

Make some performance tests compatible to other RTEMS versions which do
not allow changing the priority of a task which owns a priority
inheritance mutex.

Update #3716.

---

 testsuites/validation/tc-sem-performance.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/testsuites/validation/tc-sem-performance.c b/testsuites/validation/tc-sem-performance.c
index 0014306ddb..5861e3ee8e 100644
--- a/testsuites/validation/tc-sem-performance.c
+++ b/testsuites/validation/tc-sem-performance.c
@@ -382,9 +382,10 @@ static void RtemsSemReqPerfMtxPiReleaseOne_Setup(
   RtemsSemValPerf_Context *ctx
 )
 {
+  SetSelfPriority( PRIO_HIGH );
   ObtainMutex( ctx->mutex_id );
   Send( ctx, EVENT_OBTAIN );
-  SetPriority( ctx->worker_id, PRIO_LOW );
+  Yield();
   Send( ctx, EVENT_RELEASE );
 }
 
@@ -401,6 +402,11 @@ static void RtemsSemReqPerfMtxPiReleaseOne_Setup_Wrap( void *arg )
  */
 static void RtemsSemReqPerfMtxPiReleaseOne_Body( RtemsSemValPerf_Context *ctx )
 {
+  /*
+   * The release will unblock the worker task which has our priority.  The
+   * scheduler ensures FIFO ordering for ready threads of the same priority, so
+   * the release will not preempt us.
+   */
   ctx->status = rtems_semaphore_release( ctx->mutex_id );
 }
 
@@ -426,7 +432,7 @@ static bool RtemsSemReqPerfMtxPiReleaseOne_Teardown(
 {
   T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL );
 
-  SetPriority( ctx->worker_id, PRIO_HIGH );
+  SetSelfPriority( PRIO_NORMAL );
 
   return tic == toc;
 }
@@ -734,7 +740,7 @@ static void RtemsSemReqPerfMtxPiWaitForever_Setup(
 )
 {
   Send( ctx, EVENT_OBTAIN );
-  SetPriority( ctx->worker_id, PRIO_LOW );
+  SetSelfPriority( PRIO_VERY_HIGH );
   Send( ctx, EVENT_END | EVENT_RELEASE );
 }
 
@@ -784,8 +790,8 @@ static bool RtemsSemReqPerfMtxPiWaitForever_Teardown(
   T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL );
 
   *delta = ctx->end - ctx->begin;
-  SetPriority( ctx->worker_id, PRIO_HIGH );
   ReleaseMutex( ctx->mutex_id );
+  SetSelfPriority( PRIO_NORMAL );
 
   return tic == toc;
 }
@@ -825,7 +831,7 @@ static bool RtemsSemReqPerfMtxPiWaitForever_Teardown_Wrap(
 static void RtemsSemReqPerfMtxPiWaitTimed_Setup( RtemsSemValPerf_Context *ctx )
 {
   Send( ctx, EVENT_OBTAIN );
-  SetPriority( ctx->worker_id, PRIO_LOW );
+  SetSelfPriority( PRIO_VERY_HIGH );
   Send( ctx, EVENT_END | EVENT_RELEASE );
 }
 
@@ -873,8 +879,8 @@ static bool RtemsSemReqPerfMtxPiWaitTimed_Teardown(
   T_quiet_rsc( ctx->status, RTEMS_SUCCESSFUL );
 
   *delta = ctx->end - ctx->begin;
-  SetPriority( ctx->worker_id, PRIO_HIGH );
   ReleaseMutex( ctx->mutex_id );
+  SetSelfPriority( PRIO_NORMAL );
 
   return tic == toc;
 }



More information about the vc mailing list