diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-08-06 08:06:54 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-08-06 14:06:50 +0200 |
commit | bf931ccd4b815884f06839e122db38e807dffcfe (patch) | |
tree | 0aeb3b0b2808988815cb1af64665f9f040a38413 | |
parent | d36b0fece77976f50c8cedb988377196494ba037 (diff) |
tx-support SetSelfPriorityNoYield()
-rw-r--r-- | testsuites/validation/tx-support.c | 48 | ||||
-rw-r--r-- | testsuites/validation/tx-support.h | 4 |
2 files changed, 52 insertions, 0 deletions
diff --git a/testsuites/validation/tx-support.c b/testsuites/validation/tx-support.c index 441f6fdeee..2c4c659aaa 100644 --- a/testsuites/validation/tx-support.c +++ b/testsuites/validation/tx-support.c @@ -193,6 +193,32 @@ rtems_task_priority SetSelfPriority( rtems_task_priority priority ) return SetPriority( RTEMS_SELF, priority ); } +rtems_task_priority SetSelfPriorityNoYield( rtems_task_priority priority ) +{ + rtems_status_code sc; + rtems_id id; + + /* + * If the priority is lowered, then this sequence ensures that we do not + * carry out an implicit yield. + */ + + sc = rtems_semaphore_create( + rtems_build_name( 'T', 'E', 'M', 'P' ), + 0, + RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_PRIORITY_CEILING, + 1, + &id + ); + T_quiet_rsc_success( sc ); + + priority = SetSelfPriority( priority ); + ReleaseMutex( id ); + DeleteMutex( id ); + + return priority; +} + rtems_id GetScheduler( rtems_id id ) { rtems_status_code sc; @@ -334,27 +360,49 @@ void DeleteMutex( rtems_id id ) T_rsc_success( sc ); } } +#include <rtems/bspIo.h> +#include <rtems/score/io.h> +#include <rtems/rtems/semimpl.h> + +bool IsMutexOwner( rtems_id id ) +{ + Semaphore_Control *the_semaphore; + ISR_lock_Context lock_context; + + the_semaphore = (Semaphore_Control *) _Objects_Get( + id, + &lock_context, + &_Semaphore_Information + ); + _ISR_lock_ISR_enable( &lock_context); + return the_semaphore != NULL && the_semaphore->Core_control.Wait_queue.Queue.owner == _Thread_Get_executing(); +} void ObtainMutex( rtems_id id ) { rtems_status_code sc; + //_IO_Printf(rtems_put_char, NULL, "W%08x:%08x\n", id, rtems_task_self()); sc = rtems_semaphore_obtain( id, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); T_rsc_success( sc ); + //_IO_Printf(rtems_put_char, NULL, "O%08x:%08x\n", id, rtems_task_self()); } void ObtainMutexTimed( rtems_id id, rtems_interval ticks ) { rtems_status_code sc; + //_IO_Printf(rtems_put_char, NULL, "T%08x:%08x\n", id, rtems_task_self()); sc = rtems_semaphore_obtain( id, RTEMS_WAIT, ticks ); T_rsc_success( sc ); + //_IO_Printf(rtems_put_char, NULL, "O%08x:%08x\n", id, rtems_task_self()); } void ReleaseMutex( rtems_id id ) { rtems_status_code sc; + //_IO_Printf(rtems_put_char, NULL, "R%08x:%08x\n", id, rtems_task_self()); sc = rtems_semaphore_release( id ); T_rsc_success( sc ); } diff --git a/testsuites/validation/tx-support.h b/testsuites/validation/tx-support.h index df0e6a1333..f7600d4a07 100644 --- a/testsuites/validation/tx-support.h +++ b/testsuites/validation/tx-support.h @@ -120,6 +120,8 @@ rtems_task_priority GetSelfPriority( void ); rtems_task_priority SetSelfPriority( rtems_task_priority priority ); +rtems_task_priority SetSelfPriorityNoYield( rtems_task_priority priority ); + rtems_id GetScheduler( rtems_id id ); rtems_id GetSelfScheduler( void ); @@ -154,6 +156,8 @@ rtems_id CreateMutex( void ); rtems_id CreateMutexNoProtocol( void ); +bool IsMutexOwner( rtems_id id ); + void DeleteMutex( rtems_id id ); void ObtainMutex( rtems_id id ); |