mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-22 19:11:44 +08:00
@@ -161,7 +161,6 @@ libscore_a_SOURCES += src/smpmulticastaction.c
|
||||
libscore_a_SOURCES += src/cpuset.c
|
||||
libscore_a_SOURCES += src/cpusetprintsupport.c
|
||||
libscore_a_SOURCES += src/schedulerdefaultaskforhelp.c
|
||||
libscore_a_SOURCES += src/schedulerdefaultgetaffinity.c
|
||||
libscore_a_SOURCES += src/schedulerdefaultsetaffinity.c
|
||||
libscore_a_SOURCES += src/schedulersmp.c
|
||||
libscore_a_SOURCES += src/schedulersmpstartidle.c
|
||||
|
||||
@@ -252,6 +252,8 @@ RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_From_cpu_set_t(
|
||||
);
|
||||
}
|
||||
|
||||
extern const Processor_mask _Processor_mask_The_one_and_only;
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -203,14 +203,6 @@ typedef struct {
|
||||
);
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
/** @see _Scheduler_Get_affinity() */
|
||||
bool ( *get_affinity )(
|
||||
const Scheduler_Control *,
|
||||
Thread_Control *,
|
||||
size_t,
|
||||
cpu_set_t *
|
||||
);
|
||||
|
||||
/** @see _Scheduler_Set_affinity() */
|
||||
bool ( *set_affinity )(
|
||||
const Scheduler_Control *,
|
||||
@@ -514,24 +506,6 @@ void _Scheduler_default_Start_idle(
|
||||
);
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
/**
|
||||
* @brief Get affinity for the default scheduler.
|
||||
*
|
||||
* @param[in] scheduler The scheduler instance.
|
||||
* @param[in] thread The associated thread.
|
||||
* @param[in] cpusetsize The size of the cpuset.
|
||||
* @param[out] cpuset Affinity set containing all CPUs.
|
||||
*
|
||||
* @retval 0 Successfully got cpuset
|
||||
* @retval -1 The cpusetsize is invalid for the system
|
||||
*/
|
||||
bool _Scheduler_default_Get_affinity(
|
||||
const Scheduler_Control *scheduler,
|
||||
Thread_Control *thread,
|
||||
size_t cpusetsize,
|
||||
cpu_set_t *cpuset
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Set affinity for the default scheduler.
|
||||
*
|
||||
@@ -553,7 +527,6 @@ void _Scheduler_default_Start_idle(
|
||||
);
|
||||
|
||||
#define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
|
||||
, _Scheduler_default_Get_affinity \
|
||||
, _Scheduler_default_Set_affinity
|
||||
#else
|
||||
#define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY
|
||||
|
||||
@@ -613,20 +613,6 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Get_processor_set(
|
||||
}
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE bool _Scheduler_default_Get_affinity_body(
|
||||
const Scheduler_Control *scheduler,
|
||||
Thread_Control *the_thread,
|
||||
size_t cpusetsize,
|
||||
cpu_set_t *cpuset
|
||||
)
|
||||
{
|
||||
(void) the_thread;
|
||||
|
||||
_Scheduler_Get_processor_set( scheduler, cpusetsize, cpuset );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _Scheduler_Get_affinity(
|
||||
Thread_Control *the_thread,
|
||||
size_t cpusetsize,
|
||||
|
||||
@@ -68,7 +68,6 @@ extern "C" {
|
||||
_Scheduler_default_Cancel_job, \
|
||||
_Scheduler_default_Tick, \
|
||||
_Scheduler_SMP_Start_idle, \
|
||||
_Scheduler_priority_affinity_SMP_Get_affinity, \
|
||||
_Scheduler_priority_affinity_SMP_Set_affinity \
|
||||
}
|
||||
|
||||
@@ -102,24 +101,6 @@ void _Scheduler_priority_affinity_SMP_Unblock(
|
||||
Scheduler_Node *node
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Get affinity for the priority affinity SMP scheduler.
|
||||
*
|
||||
* @param[in] scheduler The scheduler of the thread.
|
||||
* @param[in] thread The associated thread.
|
||||
* @param[in] cpusetsize The size of the cpuset.
|
||||
* @param[in,out] cpuset The associated affinity set.
|
||||
*
|
||||
* @retval 0 Successfully got cpuset
|
||||
* @retval -1 The cpusetsize is invalid for the system
|
||||
*/
|
||||
bool _Scheduler_priority_affinity_SMP_Get_affinity(
|
||||
const Scheduler_Control *scheduler,
|
||||
Thread_Control *thread,
|
||||
size_t cpusetsize,
|
||||
cpu_set_t *cpuset
|
||||
);
|
||||
|
||||
void _Scheduler_priority_affinity_SMP_Update_priority(
|
||||
const Scheduler_Control *scheduler,
|
||||
Thread_Control *the_thread,
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <rtems/score/watchdog.h>
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
#include <rtems/score/cpuset.h>
|
||||
#include <rtems/score/processormask.h>
|
||||
#endif
|
||||
|
||||
struct _pthread_cleanup_context;
|
||||
@@ -311,6 +311,11 @@ typedef struct {
|
||||
* This list is protected by the thread scheduler lock.
|
||||
*/
|
||||
Scheduler_Node *requests;
|
||||
|
||||
/**
|
||||
* @brief The thread processor affinity set.
|
||||
*/
|
||||
Processor_mask Affinity;
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#include <rtems/score/processormask.h>
|
||||
|
||||
const Processor_mask _Processor_mask_The_one_and_only = { .__bits[ 0 ] = 1 };
|
||||
|
||||
Processor_mask_Copy_status _Processor_mask_Copy(
|
||||
long *dst,
|
||||
size_t dst_size,
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @brief Scheduler Default Get Affinity Operation
|
||||
*
|
||||
* @ingroup ScoreScheduler
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPYRIGHT (c) 2014.
|
||||
* On-Line Applications Research Corporation (OAR).
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
|
||||
bool _Scheduler_default_Get_affinity(
|
||||
const Scheduler_Control *scheduler,
|
||||
Thread_Control *thread,
|
||||
size_t cpusetsize,
|
||||
cpu_set_t *cpuset
|
||||
)
|
||||
{
|
||||
return _Scheduler_default_Get_affinity_body(
|
||||
scheduler,
|
||||
thread,
|
||||
cpusetsize,
|
||||
cpuset
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014 embedded brains GmbH. All rights reserved.
|
||||
* Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
@@ -24,33 +24,21 @@ bool _Scheduler_Get_affinity(
|
||||
cpu_set_t *cpuset
|
||||
)
|
||||
{
|
||||
const Scheduler_Control *scheduler;
|
||||
ISR_lock_Context lock_context;
|
||||
bool ok;
|
||||
|
||||
if ( !_CPU_set_Is_large_enough( cpusetsize ) ) {
|
||||
return false;
|
||||
}
|
||||
const Scheduler_Control *scheduler;
|
||||
ISR_lock_Context lock_context;
|
||||
Processor_mask *affinity;
|
||||
Processor_mask_Copy_status status;
|
||||
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
_Scheduler_Acquire_critical( scheduler, &lock_context );
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
ok = ( *scheduler->Operations.get_affinity )(
|
||||
scheduler,
|
||||
the_thread,
|
||||
cpusetsize,
|
||||
cpuset
|
||||
);
|
||||
affinity = &the_thread->Scheduler.Affinity;
|
||||
#else
|
||||
ok = _Scheduler_default_Get_affinity_body(
|
||||
scheduler,
|
||||
the_thread,
|
||||
cpusetsize,
|
||||
cpuset
|
||||
);
|
||||
affinity = &_Processor_mask_The_one_and_only;
|
||||
#endif
|
||||
status = _Processor_mask_To_cpu_set_t( affinity, cpusetsize, cpuset );
|
||||
|
||||
_Scheduler_Release_critical( scheduler, &lock_context );
|
||||
return ok;
|
||||
return status == PROCESSOR_MASK_COPY_LOSSLESS;
|
||||
}
|
||||
|
||||
@@ -611,29 +611,6 @@ Thread_Control *_Scheduler_priority_affinity_SMP_Remove_processor(
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the public scheduler specific Change Priority operation.
|
||||
*/
|
||||
bool _Scheduler_priority_affinity_SMP_Get_affinity(
|
||||
const Scheduler_Control *scheduler,
|
||||
Thread_Control *thread,
|
||||
size_t cpusetsize,
|
||||
cpu_set_t *cpuset
|
||||
)
|
||||
{
|
||||
Scheduler_priority_affinity_SMP_Node *node =
|
||||
_Scheduler_priority_affinity_SMP_Thread_get_node(thread);
|
||||
|
||||
(void) scheduler;
|
||||
|
||||
if ( node->Affinity.setsize != cpusetsize ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CPU_COPY( node->Affinity.set, cpuset );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _Scheduler_priority_affinity_SMP_Set_affinity(
|
||||
const Scheduler_Control *scheduler,
|
||||
Thread_Control *thread,
|
||||
|
||||
@@ -248,6 +248,7 @@ bool _Thread_Initialize(
|
||||
RTEMS_STATIC_ASSERT( THREAD_SCHEDULER_BLOCKED == 0, Scheduler_state );
|
||||
the_thread->Scheduler.home = scheduler;
|
||||
_ISR_lock_Initialize( &the_thread->Scheduler.Lock, "Thread Scheduler" );
|
||||
_Processor_mask_Assign( &the_thread->Scheduler.Affinity, &_SMP_Online_processors );
|
||||
_ISR_lock_Initialize( &the_thread->Wait.Lock.Default, "Thread Wait Default" );
|
||||
_Thread_queue_Gate_open( &the_thread->Wait.Lock.Tranquilizer );
|
||||
_RBTree_Initialize_node( &the_thread->Wait.Link.Registry_node );
|
||||
|
||||
@@ -84,7 +84,7 @@ void Validate_getaffinity_errors(void)
|
||||
puts(
|
||||
"Init - rtems_task_get_affinity - Invalid cpusetsize - RTEMS_INVALID_NUMBER"
|
||||
);
|
||||
sc = rtems_task_get_affinity( Init_id, sizeof(cpu_set_t) * 2, &cpuset );
|
||||
sc = rtems_task_get_affinity( Init_id, 1, &cpuset );
|
||||
rtems_test_assert( sc == RTEMS_INVALID_NUMBER );
|
||||
|
||||
/* Verify rtems_task_get_affinity validates cpuset */
|
||||
|
||||
@@ -89,7 +89,7 @@ void Validate_getaffinity_errors(void)
|
||||
|
||||
/* Verify pthread_getaffinity_np validates cpusetsize */
|
||||
puts( "Init - pthread_getaffinity_np - Invalid cpusetsize - EINVAL" );
|
||||
sc = pthread_getaffinity_np( Init_id, sizeof(cpu_set_t) * 2, &cpuset );
|
||||
sc = pthread_getaffinity_np( Init_id, 1, &cpuset );
|
||||
rtems_test_assert( sc == EINVAL );
|
||||
|
||||
/* Verify pthread_getaffinity_np validates cpuset */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2016 embedded brains GmbH. All rights reserved.
|
||||
* Copyright (c) 2014, 2017 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
@@ -207,8 +207,14 @@ static void test(void)
|
||||
cpu_set_t first_cpu;
|
||||
cpu_set_t second_cpu;
|
||||
cpu_set_t all_cpus;
|
||||
cpu_set_t online_cpus;
|
||||
uint32_t cpu_count;
|
||||
|
||||
cpu_count = rtems_get_processor_count();
|
||||
rtems_test_assert(cpu_count == 1 || cpu_count == 2);
|
||||
|
||||
rtems_test_assert(rtems_get_current_processor() == 0);
|
||||
|
||||
main_task_id = rtems_task_self();
|
||||
|
||||
CPU_ZERO(&first_cpu);
|
||||
@@ -221,9 +227,12 @@ static void test(void)
|
||||
CPU_SET(0, &all_cpus);
|
||||
CPU_SET(1, &all_cpus);
|
||||
|
||||
cpu_count = rtems_get_processor_count();
|
||||
CPU_ZERO(&online_cpus);
|
||||
CPU_SET(0, &online_cpus);
|
||||
|
||||
rtems_test_assert(rtems_get_current_processor() == 0);
|
||||
if (cpu_count > 1) {
|
||||
CPU_SET(1, &online_cpus);
|
||||
}
|
||||
|
||||
sc = rtems_scheduler_ident(SCHED_A, &scheduler_a_id);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
@@ -304,7 +313,7 @@ static void test(void)
|
||||
CPU_ZERO(&cpuset);
|
||||
sc = rtems_task_get_affinity(task_id, sizeof(cpuset), &cpuset);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert(CPU_EQUAL(&cpuset, &first_cpu));
|
||||
rtems_test_assert(CPU_EQUAL(&cpuset, &online_cpus));
|
||||
|
||||
rtems_test_assert(sched_get_priority_min(SCHED_RR) == 1);
|
||||
rtems_test_assert(sched_get_priority_max(SCHED_RR) == 254);
|
||||
@@ -326,7 +335,7 @@ static void test(void)
|
||||
CPU_ZERO(&cpuset);
|
||||
sc = rtems_task_get_affinity(task_id, sizeof(cpuset), &cpuset);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
rtems_test_assert(CPU_EQUAL(&cpuset, &second_cpu));
|
||||
rtems_test_assert(CPU_EQUAL(&cpuset, &online_cpus));
|
||||
|
||||
sc = rtems_task_set_affinity(task_id, sizeof(all_cpus), &all_cpus);
|
||||
rtems_test_assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
Reference in New Issue
Block a user