forked from Imagelibrary/rtems
score: Add processor set to scheduler context
Replace the simple processor count with the processor set owned by the scheduler instance. Update #3059.
This commit is contained in:
@@ -95,7 +95,7 @@ rtems_status_code rtems_scheduler_add_processor(
|
||||
|
||||
_ISR_lock_ISR_disable( &lock_context );
|
||||
_Scheduler_Acquire_critical( scheduler, &lock_context );
|
||||
++scheduler_context->processor_count;
|
||||
_Processor_mask_Set( &scheduler_context->Processors, cpu_index );
|
||||
cpu->Scheduler.control = scheduler;
|
||||
cpu->Scheduler.context = scheduler_context;
|
||||
( *scheduler->Operations.add_processor )( scheduler, idle );
|
||||
|
||||
@@ -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
|
||||
@@ -26,7 +26,9 @@ rtems_status_code rtems_scheduler_get_processor_set(
|
||||
cpu_set_t *cpuset
|
||||
)
|
||||
{
|
||||
const Scheduler_Control *scheduler;
|
||||
const Scheduler_Control *scheduler;
|
||||
const Processor_mask *processor_set;
|
||||
Processor_mask_Copy_status status;
|
||||
|
||||
if ( cpuset == NULL ) {
|
||||
return RTEMS_INVALID_ADDRESS;
|
||||
@@ -37,11 +39,11 @@ rtems_status_code rtems_scheduler_get_processor_set(
|
||||
return RTEMS_INVALID_ID;
|
||||
}
|
||||
|
||||
if ( !_CPU_set_Is_large_enough( cpusetsize ) ) {
|
||||
processor_set = _Scheduler_Get_processors( scheduler );
|
||||
status = _Processor_mask_To_cpu_set_t( processor_set, cpusetsize, cpuset );
|
||||
if ( status != PROCESSOR_MASK_COPY_LOSSLESS ) {
|
||||
return RTEMS_INVALID_NUMBER;
|
||||
}
|
||||
|
||||
_Scheduler_Get_processor_set( scheduler, cpusetsize, cpuset );
|
||||
|
||||
return RTEMS_SUCCESSFUL;
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ rtems_status_code rtems_scheduler_remove_processor(
|
||||
*/
|
||||
_ISR_lock_ISR_disable( &lock_context );
|
||||
_Scheduler_Acquire_critical( scheduler, &lock_context );
|
||||
processor_count = scheduler_context->processor_count - 1;
|
||||
scheduler_context->processor_count = processor_count;
|
||||
_Processor_mask_Clear( &scheduler_context->Processors, cpu_index );
|
||||
processor_count = _Processor_mask_Count( &scheduler_context->Processors );
|
||||
_Scheduler_Release_critical( scheduler, &lock_context );
|
||||
_ISR_lock_ISR_enable( &lock_context );
|
||||
|
||||
@@ -130,7 +130,7 @@ rtems_status_code rtems_scheduler_remove_processor(
|
||||
_Chain_Extract_unprotected( &scheduler_node->Thread.Scheduler_node.Chain );
|
||||
_Assert( _Chain_Is_empty( &idle->Scheduler.Scheduler_nodes ) );
|
||||
} else {
|
||||
++scheduler_context->processor_count;
|
||||
_Processor_mask_Set( &scheduler_context->Processors, cpu_index );
|
||||
}
|
||||
|
||||
cpu_self = _Thread_Dispatch_disable_critical( &lock_context );
|
||||
|
||||
@@ -227,9 +227,9 @@ typedef struct Scheduler_Context {
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
/**
|
||||
* @brief Count of processors owned by this scheduler instance.
|
||||
* @brief The set of processors owned by this scheduler instance.
|
||||
*/
|
||||
uint32_t processor_count;
|
||||
Processor_mask Processors;
|
||||
#endif
|
||||
} Scheduler_Context;
|
||||
|
||||
|
||||
@@ -589,28 +589,15 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_Has_processor_ownership(
|
||||
#endif
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Get_processor_set(
|
||||
const Scheduler_Control *scheduler,
|
||||
size_t cpusetsize,
|
||||
cpu_set_t *cpuset
|
||||
RTEMS_INLINE_ROUTINE const Processor_mask *_Scheduler_Get_processors(
|
||||
const Scheduler_Control *scheduler
|
||||
)
|
||||
{
|
||||
uint32_t cpu_count = _SMP_Get_processor_count();
|
||||
uint32_t cpu_index;
|
||||
|
||||
CPU_ZERO_S( cpusetsize, cpuset );
|
||||
|
||||
for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
|
||||
#if defined(RTEMS_SMP)
|
||||
if ( _Scheduler_Has_processor_ownership( scheduler, cpu_index ) ) {
|
||||
CPU_SET_S( (int) cpu_index, cpusetsize, cpuset );
|
||||
}
|
||||
return &_Scheduler_Get_context( scheduler )->Processors;
|
||||
#else
|
||||
(void) scheduler;
|
||||
|
||||
CPU_SET_S( (int) cpu_index, cpusetsize, cpuset );
|
||||
return &_Processor_mask_The_one_and_only;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool _Scheduler_Get_affinity(
|
||||
@@ -688,7 +675,9 @@ RTEMS_INLINE_ROUTINE uint32_t _Scheduler_Get_processor_count(
|
||||
)
|
||||
{
|
||||
#if defined(RTEMS_SMP)
|
||||
return _Scheduler_Get_context( scheduler )->processor_count;
|
||||
const Scheduler_Context *context = _Scheduler_Get_context( scheduler );
|
||||
|
||||
return _Processor_mask_Count( &context->Processors );
|
||||
#else
|
||||
(void) scheduler;
|
||||
|
||||
|
||||
@@ -97,11 +97,10 @@ static void _SMP_Start_processors( uint32_t cpu_count )
|
||||
scheduler = assignment->scheduler;
|
||||
context = _Scheduler_Get_context( scheduler );
|
||||
|
||||
++context->processor_count;
|
||||
_Processor_mask_Set( &_SMP_Online_processors, cpu_index );
|
||||
_Processor_mask_Set( &context->Processors, cpu_index );
|
||||
cpu->Scheduler.control = scheduler;
|
||||
cpu->Scheduler.context = context;
|
||||
|
||||
_Processor_mask_Set( &_SMP_Online_processors, cpu_index );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user