[rtems-central commit] spec: Thread pin/unpin with only one CPU
Sebastian Huber
sebh at rtems.org
Fri Sep 24 11:32:07 UTC 2021
Module: rtems-central
Branch: master
Commit: 1926cec9b31054e3cafc824e4b46822d8d9d600b
Changeset: http://git.rtems.org/rtems-central/commit/?id=1926cec9b31054e3cafc824e4b46822d8d9d600b
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Thu Sep 16 16:53:16 2021 +0200
spec: Thread pin/unpin with only one CPU
---
spec/score/thread/val/smp-one-cpu.yml | 92 ++++++++++++++++++++++++++++
spec/testsuites/validation-smp-one-cpu-0.yml | 23 +++++++
2 files changed, 115 insertions(+)
diff --git a/spec/score/thread/val/smp-one-cpu.yml b/spec/score/thread/val/smp-one-cpu.yml
new file mode 100644
index 0000000..ba7a707
--- /dev/null
+++ b/spec/score/thread/val/smp-one-cpu.yml
@@ -0,0 +1,92 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: RTEMS_SMP
+links: []
+test-actions:
+- action-brief: |
+ Create one worker thread to validate the thread pinning on only one
+ processor using a uniprocessor scheduler.
+ action-code: |
+ Per_CPU_Control *cpu_self;
+ Thread_Control *executing;
+
+ executing = _Thread_Get_executing();
+ SetSelfPriority( PRIO_NORMAL );
+ ctx->counter = 0;
+
+ ctx->worker_id = CreateTask( "WORK", PRIO_HIGH );
+ StartTask( ctx->worker_id, WorkerTask, ctx );
+ checks:
+ - brief: |
+ Pin the runner thread. Preempt the runner thread. Unpin the runner
+ thread.
+ code: |
+ _Thread_Pin( executing );
+
+ /* We have to preempt the runner to end up in _Thread_Do_unpin() */
+ SendEvents( ctx->worker_id, EVENT_COUNT );
+ T_eq_u32( ctx->counter, 1 );
+
+ cpu_self = _Thread_Dispatch_disable();
+ _Thread_Unpin( executing, cpu_self );
+ _Thread_Dispatch_direct( cpu_self );
+ links:
+ - role: validation
+ uid: ../req/pinning-preemptible
+ - brief: |
+ Clean up all used resources.
+ code: |
+ DeleteTask( ctx->worker_id );
+ RestoreRunnerPriority();
+ links: []
+ links: []
+test-brief: |
+ Tests SMP-specific thread behaviour using only one processor and a
+ uniprocessor scheduler.
+test-context:
+- brief: |
+ This member contains the worker thread identifier.
+ description: null
+ member: |
+ rtems_id worker_id
+- brief: |
+ This member contains a counter for EVENT_COUNT.
+ description: null
+ member: |
+ volatile uint32_t counter
+test-context-support: null
+test-description: null
+test-header: null
+test-includes:
+- rtems/score/threadimpl.h
+test-local-includes:
+- tx-support.h
+test-setup: null
+test-stop: null
+test-support: |
+ typedef ${.:/test-context-type} Context;
+
+ typedef enum {
+ EVENT_COUNT = RTEMS_EVENT_0
+ } Event;
+
+ static void WorkerTask( rtems_task_argument arg )
+ {
+ Context *ctx;
+
+ ctx = (Context *) arg;
+
+ while ( true ) {
+ rtems_event_set events;
+
+ events = ReceiveAnyEvents();
+
+ if ( ( events & EVENT_COUNT ) != 0 ) {
+ ++ctx->counter;
+ }
+ }
+ }
+test-target: testsuites/validation/tc-score-thread-smp-one-cpu.c
+test-teardown: null
+type: test-case
diff --git a/spec/testsuites/validation-smp-one-cpu-0.yml b/spec/testsuites/validation-smp-one-cpu-0.yml
new file mode 100644
index 0000000..8e1c75f
--- /dev/null
+++ b/spec/testsuites/validation-smp-one-cpu-0.yml
@@ -0,0 +1,23 @@
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
+copyrights:
+- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
+enabled-by: RTEMS_SMP
+links:
+- role: requirement-refinement
+ uid: /req/test-suites
+test-brief: |
+ This general purpose validation test suite provides enough resources to run
+ basic tests for all specified managers and functions in a configuration with
+ exactly one processor and an uniprocessor scheduler.
+test-code: |
+ const char rtems_test_name[] = "${.:/test-suite-name}";
+
+ #define CONFIGURE_MAXIMUM_PROCESSORS 1
+
+ #include "ts-default.h"
+test-description: null
+test-includes: []
+test-local-includes: []
+test-suite-name: ValidationSmpOneCpu0
+test-target: testsuites/validation/ts-validation-smp-one-cpu-0.c
+type: test-suite
More information about the vc
mailing list