forked from Imagelibrary/rtems
score: Delete _Scheduler_Ask_for_help_if_necessary
Delete Thread_Control::Resource_node. Update #2556.
This commit is contained in:
@@ -196,100 +196,6 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Schedule( Thread_Control *the_thread )
|
||||
_Scheduler_Release_critical( scheduler, &lock_context );
|
||||
}
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
typedef struct {
|
||||
Thread_Control *needs_help;
|
||||
Thread_Control *next_needs_help;
|
||||
} Scheduler_Ask_for_help_context ;
|
||||
|
||||
RTEMS_INLINE_ROUTINE bool _Scheduler_Ask_for_help_visitor(
|
||||
Resource_Node *resource_node,
|
||||
void *arg
|
||||
)
|
||||
{
|
||||
bool done;
|
||||
Scheduler_Ask_for_help_context *help_context = arg;
|
||||
Thread_Control *previous_needs_help = help_context->needs_help;
|
||||
Thread_Control *next_needs_help;
|
||||
Thread_Control *offers_help =
|
||||
THREAD_RESOURCE_NODE_TO_THREAD( resource_node );
|
||||
const Scheduler_Control *scheduler = _Scheduler_Get_own( offers_help );
|
||||
|
||||
next_needs_help = ( *scheduler->Operations.ask_for_help_X )(
|
||||
scheduler,
|
||||
offers_help,
|
||||
previous_needs_help
|
||||
);
|
||||
|
||||
done = next_needs_help != previous_needs_help;
|
||||
|
||||
if ( done ) {
|
||||
help_context->next_needs_help = next_needs_help;
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Ask threads depending on resources owned by the thread for help.
|
||||
*
|
||||
* A thread is in need for help if it lost its assigned processor due to
|
||||
* pre-emption by a higher priority thread or it was not possible to assign it
|
||||
* a processor since its priority is to low on its current scheduler instance.
|
||||
*
|
||||
* The run-time of this function depends on the size of the resource tree of
|
||||
* the thread needing help and other resource trees in case threads in need for
|
||||
* help are produced during this operation.
|
||||
*
|
||||
* @param[in] needs_help The thread needing help.
|
||||
*/
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help_X(
|
||||
Thread_Control *needs_help
|
||||
)
|
||||
{
|
||||
do {
|
||||
const Scheduler_Control *scheduler = _Scheduler_Get_own( needs_help );
|
||||
|
||||
needs_help = ( *scheduler->Operations.ask_for_help_X )(
|
||||
scheduler,
|
||||
needs_help,
|
||||
needs_help
|
||||
);
|
||||
|
||||
if ( needs_help != NULL ) {
|
||||
Scheduler_Ask_for_help_context help_context = { needs_help, NULL };
|
||||
|
||||
_Resource_Iterate(
|
||||
&needs_help->Resource_node,
|
||||
_Scheduler_Ask_for_help_visitor,
|
||||
&help_context
|
||||
);
|
||||
|
||||
needs_help = help_context.next_needs_help;
|
||||
}
|
||||
} while ( needs_help != NULL );
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE void _Scheduler_Ask_for_help_if_necessary(
|
||||
Thread_Control *needs_help
|
||||
)
|
||||
{
|
||||
if (
|
||||
needs_help != NULL
|
||||
&& _Resource_Node_owns_resources( &needs_help->Resource_node )
|
||||
) {
|
||||
Scheduler_Node *node = _Thread_Scheduler_get_own_node( needs_help );
|
||||
|
||||
if (
|
||||
node->help_state != SCHEDULER_HELP_ACTIVE_RIVAL
|
||||
|| _Scheduler_Node_get_user( node ) != needs_help
|
||||
) {
|
||||
_Scheduler_Ask_for_help_X( needs_help );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Scheduler yield with a particular thread.
|
||||
*
|
||||
@@ -320,7 +226,6 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Yield( Thread_Control *the_thread )
|
||||
the_thread,
|
||||
_Thread_Scheduler_get_home_node( the_thread )
|
||||
);
|
||||
_Scheduler_Ask_for_help_if_necessary( needs_help );
|
||||
_Scheduler_Release_critical( scheduler, &lock_context );
|
||||
|
||||
if ( needs_help != the_thread ) {
|
||||
@@ -455,7 +360,6 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Unblock( Thread_Control *the_thread )
|
||||
the_thread,
|
||||
scheduler_node
|
||||
);
|
||||
_Scheduler_Ask_for_help_if_necessary( needs_help );
|
||||
_Scheduler_Release_critical( scheduler, &lock_context );
|
||||
|
||||
if ( needs_help != the_thread ) {
|
||||
@@ -525,18 +429,16 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Update_priority( Thread_Control *the_thread
|
||||
Scheduler_Node *scheduler_node;
|
||||
const Scheduler_Control *scheduler;
|
||||
ISR_lock_Context lock_context;
|
||||
Thread_Control *needs_help;
|
||||
|
||||
scheduler_node = SCHEDULER_NODE_OF_THREAD_SCHEDULER_NODE( node );
|
||||
scheduler = _Scheduler_Node_get_scheduler( scheduler_node );
|
||||
|
||||
_Scheduler_Acquire_critical( scheduler, &lock_context );
|
||||
needs_help = ( *scheduler->Operations.update_priority )(
|
||||
( *scheduler->Operations.update_priority )(
|
||||
scheduler,
|
||||
the_thread,
|
||||
scheduler_node
|
||||
);
|
||||
_Scheduler_Ask_for_help_if_necessary( needs_help );
|
||||
_Scheduler_Release_critical( scheduler, &lock_context );
|
||||
|
||||
node = _Chain_Next( node );
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <rtems/score/isrlock.h>
|
||||
#include <rtems/score/object.h>
|
||||
#include <rtems/score/priority.h>
|
||||
#include <rtems/score/resource.h>
|
||||
#include <rtems/score/schedulernode.h>
|
||||
#include <rtems/score/stack.h>
|
||||
#include <rtems/score/states.h>
|
||||
@@ -769,13 +768,6 @@ struct _Thread_Control {
|
||||
SMP_lock_Stats Potpourri_stats;
|
||||
#endif
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
/**
|
||||
* @brief Resource node to build a dependency tree in case this thread owns
|
||||
* resources or depends on a resource.
|
||||
*/
|
||||
Resource_Node Resource_node;
|
||||
#endif
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
/** This field is true if the thread is offered globally */
|
||||
bool is_global;
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <rtems/score/interr.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/objectimpl.h>
|
||||
#include <rtems/score/resourceimpl.h>
|
||||
#include <rtems/score/schedulernodeimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/status.h>
|
||||
@@ -79,9 +78,6 @@ extern Thread_Control *_Thread_Allocated_fp;
|
||||
#endif
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
#define THREAD_RESOURCE_NODE_TO_THREAD( node ) \
|
||||
RTEMS_CONTAINER_OF( node, Thread_Control, Resource_node )
|
||||
|
||||
#define THREAD_OF_SCHEDULER_HELP_NODE( node ) \
|
||||
RTEMS_CONTAINER_OF( node, Thread_Control, Scheduler.Help_node )
|
||||
#endif
|
||||
@@ -974,11 +970,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Is_joinable(
|
||||
* @brief Returns true if the thread owns resources, and false otherwise.
|
||||
*
|
||||
* Resources are accounted with the Thread_Control::resource_count resource
|
||||
* counter. This counter is used by semaphore objects for example.
|
||||
*
|
||||
* In addition to the resource counter there is a resource dependency tree
|
||||
* available on SMP configurations. In case this tree is non-empty, then the
|
||||
* thread owns resources.
|
||||
* counter. This counter is used by mutex objects for example.
|
||||
*
|
||||
* @param[in] the_thread The thread.
|
||||
*/
|
||||
@@ -986,14 +978,7 @@ RTEMS_INLINE_ROUTINE bool _Thread_Owns_resources(
|
||||
const Thread_Control *the_thread
|
||||
)
|
||||
{
|
||||
bool owns_resources = the_thread->resource_count != 0;
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
owns_resources = owns_resources
|
||||
|| _Resource_Node_owns_resources( &the_thread->Resource_node );
|
||||
#endif
|
||||
|
||||
return owns_resources;
|
||||
return the_thread->resource_count != 0;
|
||||
}
|
||||
|
||||
#if defined(RTEMS_SMP)
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#endif
|
||||
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/resourceimpl.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
#include <rtems/score/stackimpl.h>
|
||||
#include <rtems/score/tls.h>
|
||||
@@ -237,7 +236,6 @@ bool _Thread_Initialize(
|
||||
the_thread->Scheduler.control = scheduler;
|
||||
the_thread->Scheduler.own_node = scheduler_node;
|
||||
the_thread->Scheduler.node = scheduler_node;
|
||||
_Resource_Node_initialize( &the_thread->Resource_node );
|
||||
_ISR_lock_Initialize( &the_thread->Scheduler.Lock, "Thread Scheduler" );
|
||||
_ISR_lock_Initialize( &the_thread->Wait.Lock.Default, "Thread Wait Default" );
|
||||
_Thread_queue_Gate_open( &the_thread->Wait.Lock.Tranquilizer );
|
||||
|
||||
Reference in New Issue
Block a user