summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-10-11 09:59:06 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-11-11 16:10:25 +0100
commitaaf293c923c4a5ea706443f524c45143107aa537 (patch)
tree4212746a06a2645067c19d4f2add972ddaa58582
parent48f9950556cf0c404bb16dded04d7f1b71567cca (diff)
tx-support
-rw-r--r--testsuites/validation/tx-thread-queue.c53
-rw-r--r--testsuites/validation/tx-thread-queue.h13
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 );