forked from Imagelibrary/rtems
score: Fix _Scheduler_EDF_SMP_Set_affinity()
Commit 8744498752 broke the
_Scheduler_EDF_SMP_Set_affinity() implementation. We must test the
overall affinity against the online processors.
This commit is contained in:
@@ -656,22 +656,20 @@ bool _Scheduler_EDF_SMP_Set_affinity(
|
||||
)
|
||||
{
|
||||
Scheduler_Context *context;
|
||||
Processor_mask a;
|
||||
uint32_t count;
|
||||
Processor_mask local_affinity;
|
||||
uint32_t rqi;
|
||||
|
||||
context = _Scheduler_Get_context( scheduler );
|
||||
_Processor_mask_And( &a, &context->Processors, affinity );
|
||||
count = _Processor_mask_Count( &a );
|
||||
_Processor_mask_And( &local_affinity, &context->Processors, affinity );
|
||||
|
||||
if ( count == 0 ) {
|
||||
if ( _Processor_mask_Is_zero( &local_affinity ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( count == _SMP_Processor_count ) {
|
||||
if ( _Processor_mask_Is_equal( affinity, &_SMP_Online_processors ) ) {
|
||||
rqi = 0;
|
||||
} else {
|
||||
rqi = _Processor_mask_Find_last_set( &a );
|
||||
rqi = _Processor_mask_Find_last_set( &local_affinity );
|
||||
}
|
||||
|
||||
_Scheduler_SMP_Set_affinity(
|
||||
|
||||
@@ -478,6 +478,17 @@ smpschededf03_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_smpschededf03) \
|
||||
endif
|
||||
endif
|
||||
|
||||
if HAS_SMP
|
||||
if TEST_smpschededf04
|
||||
smp_tests += smpschededf04
|
||||
smp_screens += smpschededf04/smpschededf04.scn
|
||||
smp_docs += smpschededf04/smpschededf04.doc
|
||||
smpschededf04_SOURCES = smpschededf04/init.c
|
||||
smpschededf04_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_smpschededf04) \
|
||||
$(support_includes)
|
||||
endif
|
||||
endif
|
||||
|
||||
if HAS_SMP
|
||||
if TEST_smpschedsem01
|
||||
smp_tests += smpschedsem01
|
||||
|
||||
@@ -74,6 +74,7 @@ RTEMS_TEST_CHECK([smpschedaffinity05])
|
||||
RTEMS_TEST_CHECK([smpschededf01])
|
||||
RTEMS_TEST_CHECK([smpschededf02])
|
||||
RTEMS_TEST_CHECK([smpschededf03])
|
||||
RTEMS_TEST_CHECK([smpschededf04])
|
||||
RTEMS_TEST_CHECK([smpschedsem01])
|
||||
RTEMS_TEST_CHECK([smpscheduler01])
|
||||
RTEMS_TEST_CHECK([smpscheduler02])
|
||||
|
||||
141
testsuites/smptests/smpschededf04/init.c
Normal file
141
testsuites/smptests/smpschededf04/init.c
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2018 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "tmacros.h"
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
const char rtems_test_name[] = "SMPSCHEDEDF 4";
|
||||
|
||||
#define CPU_COUNT 4
|
||||
|
||||
#define TASK_COUNT 2
|
||||
|
||||
#define MAIN rtems_build_name('M', 'A', 'I', 'N')
|
||||
|
||||
#define OTHER rtems_build_name('O', 'T', 'H', 'R')
|
||||
|
||||
typedef struct {
|
||||
rtems_id other_scheduler_id;
|
||||
rtems_id task_ids[TASK_COUNT];
|
||||
} test_context;
|
||||
|
||||
static test_context test_instance;
|
||||
|
||||
static void do_nothing_task(rtems_task_argument arg)
|
||||
{
|
||||
(void) arg;
|
||||
|
||||
#if CPU_PROVIDES_IDLE_THREAD_BODY == TRUE
|
||||
_CPU_Thread_Idle_body(0);
|
||||
#else
|
||||
while (true) {
|
||||
/* Do nothing */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void test(void)
|
||||
{
|
||||
test_context *ctx;
|
||||
rtems_status_code sc;
|
||||
size_t i;
|
||||
|
||||
ctx = &test_instance;
|
||||
|
||||
for (i = 0; i < TASK_COUNT; ++i) {
|
||||
sc = rtems_task_create(
|
||||
rtems_build_name('N', 'B', 'D', 'Y'),
|
||||
2,
|
||||
RTEMS_MINIMUM_STACK_SIZE,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&ctx->task_ids[i]
|
||||
);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
sc = rtems_task_start(ctx->task_ids[i], do_nothing_task, 0);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
}
|
||||
|
||||
sc = rtems_scheduler_ident(OTHER, &ctx->other_scheduler_id);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
for (i = 0; i < TASK_COUNT; ++i) {
|
||||
const Per_CPU_Control *cpu;
|
||||
|
||||
sc = rtems_task_set_scheduler(ctx->task_ids[i], ctx->other_scheduler_id, 2);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
cpu = _Per_CPU_Get_by_index(CPU_COUNT - 1 - i);
|
||||
rtems_test_assert(cpu->heir->Object.id == ctx->task_ids[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < TASK_COUNT; ++i) {
|
||||
sc = rtems_task_delete(ctx->task_ids[i]);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
}
|
||||
}
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
TEST_BEGIN();
|
||||
|
||||
if (rtems_get_processor_count() == CPU_COUNT) {
|
||||
test();
|
||||
} else {
|
||||
puts("warning: wrong processor count to run the test");
|
||||
}
|
||||
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS (1 + TASK_COUNT)
|
||||
|
||||
#define CONFIGURE_MAXIMUM_PROCESSORS CPU_COUNT
|
||||
|
||||
#define CONFIGURE_SCHEDULER_EDF_SMP
|
||||
|
||||
#include <rtems/scheduler.h>
|
||||
|
||||
RTEMS_SCHEDULER_EDF_SMP(a, CONFIGURE_MAXIMUM_PROCESSORS);
|
||||
|
||||
RTEMS_SCHEDULER_EDF_SMP(b, CONFIGURE_MAXIMUM_PROCESSORS);
|
||||
|
||||
#define CONFIGURE_SCHEDULER_TABLE_ENTRIES \
|
||||
RTEMS_SCHEDULER_TABLE_EDF_SMP(a, MAIN), \
|
||||
RTEMS_SCHEDULER_TABLE_EDF_SMP(b, OTHER)
|
||||
|
||||
#define CONFIGURE_SCHEDULER_ASSIGNMENTS \
|
||||
RTEMS_SCHEDULER_ASSIGN(0, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_MANDATORY), \
|
||||
RTEMS_SCHEDULER_ASSIGN_NO_SCHEDULER, \
|
||||
RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL), \
|
||||
RTEMS_SCHEDULER_ASSIGN(1, RTEMS_SCHEDULER_ASSIGN_PROCESSOR_OPTIONAL)
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
12
testsuites/smptests/smpschededf04/smpschededf04.doc
Normal file
12
testsuites/smptests/smpschededf04/smpschededf04.doc
Normal file
@@ -0,0 +1,12 @@
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: smpschededf04
|
||||
|
||||
directives:
|
||||
|
||||
- _Scheduler_EDF_SMP_Set_affinity()
|
||||
|
||||
concepts:
|
||||
|
||||
- Ensure that _Scheduler_EDF_SMP_Set_affinity() works correctly in a
|
||||
clustered scheduling setup.
|
||||
7
testsuites/smptests/smpschededf04/smpschededf04.scn
Normal file
7
testsuites/smptests/smpschededf04/smpschededf04.scn
Normal file
@@ -0,0 +1,7 @@
|
||||
*** BEGIN OF TEST SMPSCHEDEDF 4 ***
|
||||
*** TEST VERSION: 5.0.0.a76f83b01412e5a6c18f8ab950a027014e24b4fb
|
||||
*** TEST STATE: EXPECTED-PASS
|
||||
*** TEST BUILD: RTEMS_SMP
|
||||
*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB fec257a64320c24e3a7599df68cfe59ff0c94d8e, Newlib 3.0.0)
|
||||
|
||||
*** END OF TEST SMPSCHEDEDF 4 ***
|
||||
Reference in New Issue
Block a user