diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-10-11 09:59:06 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-11-09 15:47:11 +0100 |
commit | b63e0f52deab8f355e53f6dcb60e74d1286feff0 (patch) | |
tree | dd3d343a9ec76dffabc4ff920d143e6059d755fd | |
parent | 233bbe876ba13a6426b4da4629e2bbf464c81243 (diff) |
tx-support
-rw-r--r-- | testsuites/validation/tx-thread-queue.c | 53 | ||||
-rw-r--r-- | testsuites/validation/tx-thread-queue.h | 13 |
2 files changed, 57 insertions, 9 deletions
diff --git a/testsuites/validation/tx-thread-queue.c b/testsuites/validation/tx-thread-queue.c index 30d5e6f3cf..49c8f7eda9 100644 --- a/testsuites/validation/tx-thread-queue.c +++ b/testsuites/validation/tx-thread-queue.c @@ -42,6 +42,7 @@ #include "tx-support.h" #include "ts-config.h" +#include <rtems/score/threadimpl.h> #include <rtems/rtems/semimpl.h> void TQSend( @@ -248,16 +249,18 @@ void TQSetScheduler( #endif } -static void Enqueue( TQContext *ctx, TQWorkerKind worker, TQWait wait ) +static void Count( TQContext *ctx, TQWorkerKind worker ) { - uint32_t counter; + unsigned int counter; - ctx->status[ worker ] = TQEnqueue( ctx, wait ); + counter = _Atomic_Fetch_add_uint( &ctx->counter, 1, ATOMIC_ORDER_RELAXED ); + ctx->worker_counter[ worker ] = counter + 1; +} - counter = ctx->counter; - ++counter; - ctx->counter = counter; - ctx->worker_counter[ worker ] = counter; +static void Enqueue( TQContext *ctx, TQWorkerKind worker, TQWait wait ) +{ + ctx->status[ worker ] = TQEnqueue( ctx, wait ); + Count( ctx, worker ); } static void ThreadQueueDeadlock( @@ -369,6 +372,14 @@ static void Worker( rtems_task_argument arg, TQWorkerKind worker ) TQMutexRelease( ctx, TQ_MUTEX_C ); } + if ( ( events & TQ_EVENT_MUTEX_D_OBTAIN ) != 0 ) { + TQMutexObtain( ctx, TQ_MUTEX_D ); + } + + if ( ( events & TQ_EVENT_MUTEX_D_RELEASE ) != 0 ) { + TQMutexRelease( ctx, TQ_MUTEX_D ); + } + if ( ( events & TQ_EVENT_MUTEX_NO_PROTOCOL_OBTAIN ) != 0 ) { TQMutexObtain( ctx, TQ_MUTEX_NO_PROTOCOL ); } @@ -385,6 +396,18 @@ static void Worker( rtems_task_argument arg, TQWorkerKind worker ) TQMutexRelease( ctx, TQ_MUTEX_FIFO ); } + if ( ( events & TQ_EVENT_PIN ) != 0 ) { + _Thread_Pin( _Thread_Get_executing() ); + } + + if ( ( events & TQ_EVENT_UNPIN ) != 0 ) { + Per_CPU_Control *cpu_self; + + cpu_self = _Thread_Dispatch_disable(); + _Thread_Unpin( _Thread_Get_executing(), cpu_self ); + _Thread_Dispatch_direct( cpu_self ); + } + if ( ( events & TQ_EVENT_SCHEDULER_RECORD_STOP ) != 0 ) { TQSchedulerRecordStop( ctx ); } @@ -393,6 +416,10 @@ static void Worker( rtems_task_argument arg, TQWorkerKind worker ) SendEvents( ctx->runner_id, TQ_EVENT_RUNNER_SYNC ); } + if ( ( events & TQ_EVENT_COUNT ) != 0 ) { + Count( ctx, worker ); + } + if ( ( events & TQ_EVENT_BUSY_WAIT ) != 0 ) { while ( ctx->busy_wait[ worker ] ) { /* Wait */ @@ -685,6 +712,18 @@ const T_scheduler_event *TQGetNextUpdatePriority( ); } +const T_scheduler_event *TQGetNextAskForHelp( + TQContext *ctx, + size_t *index +) +{ + return T_scheduler_next( + &ctx->scheduler_log.header, + T_SCHEDULER_ASK_FOR_HELP, + index + ); +} + void TQDoNothing( TQContext *ctx ) { (void) ctx; diff --git a/testsuites/validation/tx-thread-queue.h b/testsuites/validation/tx-thread-queue.h index 3d462ba449..d9a1a4db8d 100644 --- a/testsuites/validation/tx-thread-queue.h +++ b/testsuites/validation/tx-thread-queue.h @@ -40,6 +40,7 @@ #include "tx-support.h" #include <rtems/test-scheduler.h> +#include <rtems/score/atomic.h> #include <rtems/score/status.h> #include <setjmp.h> @@ -83,6 +84,7 @@ typedef enum { TQ_MUTEX_A, TQ_MUTEX_B, TQ_MUTEX_C, + TQ_MUTEX_D, TQ_MUTEX_NO_PROTOCOL, TQ_MUTEX_FIFO, TQ_MUTEX_COUNT @@ -129,7 +131,12 @@ typedef enum { TQ_EVENT_MUTEX_C_RELEASE = RTEMS_EVENT_21, TQ_EVENT_MUTEX_FIFO_OBTAIN = RTEMS_EVENT_22, TQ_EVENT_MUTEX_FIFO_RELEASE = RTEMS_EVENT_23, - TQ_EVENT_ENQUEUE_TIMED = RTEMS_EVENT_24 + TQ_EVENT_ENQUEUE_TIMED = RTEMS_EVENT_24, + TQ_EVENT_MUTEX_D_OBTAIN = RTEMS_EVENT_25, + TQ_EVENT_MUTEX_D_RELEASE = RTEMS_EVENT_26, + TQ_EVENT_PIN = RTEMS_EVENT_27, + TQ_EVENT_UNPIN = RTEMS_EVENT_28, + TQ_EVENT_COUNT = RTEMS_EVENT_29 } TQEvent; typedef enum { @@ -201,7 +208,7 @@ typedef struct TQContext { /** * @brief This member provides the counter used for the worker counters. */ - uint32_t counter; + Atomic_Uint counter; /** * @brief When a worker returned from TQEnqueue() the counter is incremented @@ -402,6 +409,8 @@ const T_scheduler_event *TQGetNextUpdatePriority( size_t *index ); +const T_scheduler_event *TQGetNextAskForHelp( TQContext *ctx, size_t *index ); + void TQDoNothing( TQContext *ctx ); Status_Control TQDoNothingSuccessfully( TQContext *ctx ); |