diff options
Diffstat (limited to '')
-rw-r--r-- | testsuites/validation/tc-sem-performance.c | 114 |
1 files changed, 96 insertions, 18 deletions
diff --git a/testsuites/validation/tc-sem-performance.c b/testsuites/validation/tc-sem-performance.c index 5bbff6a587..5861e3ee8e 100644 --- a/testsuites/validation/tc-sem-performance.c +++ b/testsuites/validation/tc-sem-performance.c @@ -3,11 +3,11 @@ /** * @file * - * @ingroup RTEMSTestCaseRtemsSemValPerf + * @ingroup RtemsSemValPerf */ /* - * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * Copyright (C) 2021 embedded brains GmbH & Co. KG * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -59,9 +59,9 @@ #include <rtems/test.h> /** - * @defgroup RTEMSTestCaseRtemsSemValPerf spec:/rtems/sem/val/perf + * @defgroup RtemsSemValPerf spec:/rtems/sem/val/perf * - * @ingroup RTEMSTestSuiteTestsuitesPerformanceNoClock0 + * @ingroup TestsuitesPerformanceNoClock0 * * @brief This test case provides a context to run @ref RTEMSAPIClassicSem * performance tests. @@ -112,15 +112,17 @@ typedef struct { static RtemsSemValPerf_Context RtemsSemValPerf_Instance; -typedef RtemsSemValPerf_Context Context; +#define EVENT_END RTEMS_EVENT_0 + +#define EVENT_OBTAIN RTEMS_EVENT_1 + +#define EVENT_OBTAIN_END RTEMS_EVENT_2 -typedef enum { - EVENT_END = RTEMS_EVENT_0, - EVENT_OBTAIN = RTEMS_EVENT_1, - EVENT_OBTAIN_END = RTEMS_EVENT_2, - EVENT_RELEASE = RTEMS_EVENT_3, - EVENT_RELEASE_END = RTEMS_EVENT_4 -} Event; +#define EVENT_RELEASE RTEMS_EVENT_3 + +#define EVENT_RELEASE_END RTEMS_EVENT_4 + +typedef RtemsSemValPerf_Context Context; static void Send( const Context *ctx, rtems_event_set events ) { @@ -236,6 +238,12 @@ static T_fixture RtemsSemValPerf_Fixture = { }; /** + * @defgroup RtemsSemReqPerfMtxPiObtain spec:/rtems/sem/req/perf-mtx-pi-obtain + * + * @{ + */ + +/** * @brief Obtain the available mutex. */ static void RtemsSemReqPerfMtxPiObtain_Body( RtemsSemValPerf_Context *ctx ) @@ -287,6 +295,15 @@ static bool RtemsSemReqPerfMtxPiObtain_Teardown_Wrap( return RtemsSemReqPerfMtxPiObtain_Teardown( ctx, delta, tic, toc, retry ); } +/** @} */ + +/** + * @defgroup RtemsSemReqPerfMtxPiRelease \ + * spec:/rtems/sem/req/perf-mtx-pi-release + * + * @{ + */ + /** * @brief Obtain the mutex. */ @@ -349,6 +366,15 @@ static bool RtemsSemReqPerfMtxPiRelease_Teardown_Wrap( return RtemsSemReqPerfMtxPiRelease_Teardown( ctx, delta, tic, toc, retry ); } +/** @} */ + +/** + * @defgroup RtemsSemReqPerfMtxPiReleaseOne \ + * spec:/rtems/sem/req/perf-mtx-pi-release-one + * + * @{ + */ + /** * @brief Let one task wait on the mutex. */ @@ -356,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 ); } @@ -375,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 ); } @@ -400,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; } @@ -425,8 +457,17 @@ static bool RtemsSemReqPerfMtxPiReleaseOne_Teardown_Wrap( ); } +/** @} */ + #if defined(RTEMS_SMP) /** + * @defgroup RtemsSemReqPerfMtxPiReleaseOtherCpu \ + * spec:/rtems/sem/req/perf-mtx-pi-release-other-cpu + * + * @{ + */ + +/** * @brief Move worker to scheduler B. */ static void RtemsSemReqPerfMtxPiReleaseOtherCpu_Prepare( @@ -524,9 +565,18 @@ static void RtemsSemReqPerfMtxPiReleaseOtherCpu_Cleanup( { SetScheduler( ctx->worker_id, SCHEDULER_A_ID, PRIO_HIGH ); } + +/** @} */ #endif /** + * @defgroup RtemsSemReqPerfMtxPiReleasePreempt \ + * spec:/rtems/sem/req/perf-mtx-pi-release-preempt + * + * @{ + */ + +/** * @brief Let one task wait on the mutex. */ static void RtemsSemReqPerfMtxPiReleasePreempt_Setup( @@ -603,6 +653,14 @@ static bool RtemsSemReqPerfMtxPiReleasePreempt_Teardown_Wrap( ); } +/** @} */ + +/** + * @defgroup RtemsSemReqPerfMtxPiTry spec:/rtems/sem/req/perf-mtx-pi-try + * + * @{ + */ + /** * @brief Make the mutex unavailable. */ @@ -665,6 +723,15 @@ static void RtemsSemReqPerfMtxPiTry_Cleanup( RtemsSemValPerf_Context *ctx ) Send( ctx, EVENT_RELEASE ); } +/** @} */ + +/** + * @defgroup RtemsSemReqPerfMtxPiWaitForever \ + * spec:/rtems/sem/req/perf-mtx-pi-wait-forever + * + * @{ + */ + /** * @brief Make the mutex unavailable. */ @@ -673,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 ); } @@ -723,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; } @@ -749,13 +816,22 @@ static bool RtemsSemReqPerfMtxPiWaitForever_Teardown_Wrap( ); } +/** @} */ + +/** + * @defgroup RtemsSemReqPerfMtxPiWaitTimed \ + * spec:/rtems/sem/req/perf-mtx-pi-wait-timed + * + * @{ + */ + /** * @brief Make the mutex unavailable. */ 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 ); } @@ -803,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; } @@ -823,6 +899,8 @@ static bool RtemsSemReqPerfMtxPiWaitTimed_Teardown_Wrap( return RtemsSemReqPerfMtxPiWaitTimed_Teardown( ctx, delta, tic, toc, retry ); } +/** @} */ + /** * @fn void T_case_body_RtemsSemValPerf( void ) */ |