score: Add _Scheduler_priority_Get_scheduler_info

Add and use _Scheduler_priority_Get_scheduler_info().
This commit is contained in:
Sebastian Huber
2013-08-08 08:45:33 +02:00
parent e5ca54c996
commit 0c551f76e5
4 changed files with 44 additions and 56 deletions

View File

@@ -57,6 +57,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_initialize(void)
_Chain_Initialize_empty( &ready_queues[index] );
}
RTEMS_INLINE_ROUTINE Scheduler_priority_Per_thread *
_Scheduler_priority_Get_scheduler_info( Thread_Control *thread )
{
return ( Scheduler_priority_Per_thread * ) thread->scheduler_info;
}
/**
* @brief Put a thread to the ready queue.
*
@@ -68,15 +74,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue(
Thread_Control *the_thread
)
{
Scheduler_priority_Per_thread *sched_info;
Chain_Control *ready;
Scheduler_priority_Per_thread *sched_info_of_thread =
_Scheduler_priority_Get_scheduler_info( the_thread );
Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
ready = sched_info->ready_chain;
_Priority_bit_map_Add( &sched_info->Priority_map );
_Chain_Append_unprotected( ready, &the_thread->Object.Node );
_Chain_Append_unprotected( ready_chain, &the_thread->Object.Node );
_Priority_bit_map_Add( &sched_info_of_thread->Priority_map );
}
/**
@@ -92,16 +95,12 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_enqueue_first(
Thread_Control *the_thread
)
{
Scheduler_priority_Per_thread *sched_info;
Scheduler_priority_Per_thread *sched_info_of_thread =
_Scheduler_priority_Get_scheduler_info( the_thread );
Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
_Priority_bit_map_Add( &sched_info->Priority_map );
_Chain_Prepend_unprotected(
sched_info->ready_chain,
&the_thread->Object.Node
);
_Chain_Prepend_unprotected( ready_chain, &the_thread->Object.Node );
_Priority_bit_map_Add( &sched_info_of_thread->Priority_map );
}
/**
@@ -116,15 +115,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_extract(
Thread_Control *the_thread
)
{
Scheduler_priority_Per_thread *sched_info;
Chain_Control *ready;
Scheduler_priority_Per_thread *sched_info_of_thread =
_Scheduler_priority_Get_scheduler_info( the_thread );
Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
ready = sched_info->ready_chain;
if ( _Chain_Has_only_one_node( ready ) ) {
_Chain_Initialize_empty( ready );
_Priority_bit_map_Remove( &sched_info->Priority_map );
if ( _Chain_Has_only_one_node( ready_chain ) ) {
_Chain_Initialize_empty( ready_chain );
_Priority_bit_map_Remove( &sched_info_of_thread->Priority_map );
} else {
_Chain_Extract_unprotected( &the_thread->Object.Node );
}
@@ -163,17 +160,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_priority_Ready_queue_requeue(
Thread_Control *the_thread
)
{
Scheduler_priority_Per_thread *sched_info;
Scheduler_priority_Per_thread *sched_info_of_thread =
_Scheduler_priority_Get_scheduler_info( the_thread );
Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
if ( !_Chain_Has_only_one_node( sched_info->ready_chain ) ) {
if ( !_Chain_Has_only_one_node( ready_chain ) ) {
_Chain_Extract_unprotected( &the_thread->Object.Node );
_Chain_Append_unprotected(
sched_info->ready_chain,
&the_thread->Object.Node
);
_Chain_Append_unprotected( ready_chain, &the_thread->Object.Node );
}
}

View File

@@ -18,21 +18,17 @@
#include "config.h"
#endif
#include <rtems/system.h>
#include <rtems/config.h>
#include <rtems/score/scheduler.h>
#include <rtems/score/schedulerpriority.h>
#include <rtems/score/wkspace.h>
void* _Scheduler_priority_Allocate (
void *_Scheduler_priority_Allocate (
Thread_Control *the_thread
)
{
void *sched;
Scheduler_priority_Per_thread *sched_info_of_thread =
_Workspace_Allocate( sizeof( *sched_info_of_thread ) );
sched = _Workspace_Allocate( sizeof(Scheduler_priority_Per_thread) );
the_thread->scheduler_info = sched_info_of_thread;
the_thread->scheduler_info = (Scheduler_priority_Per_thread*) sched;
return sched;
return sched_info_of_thread;
}

View File

@@ -25,16 +25,16 @@ void _Scheduler_priority_Update(
Thread_Control *the_thread
)
{
Scheduler_priority_Per_thread *sched_info;
Scheduler_priority_Per_thread *sched_info_of_thread =
_Scheduler_priority_Get_scheduler_info( the_thread );
Chain_Control *rq;
sched_info = (Scheduler_priority_Per_thread *) the_thread->scheduler_info;
rq = (Chain_Control *) _Scheduler.information;
rq = (Chain_Control *) _Scheduler.information;
sched_info->ready_chain = &rq[ the_thread->current_priority ];
sched_info_of_thread->ready_chain = &rq[ the_thread->current_priority ];
_Priority_bit_map_Initialize_information(
&sched_info->Priority_map,
&sched_info_of_thread->Priority_map,
the_thread->current_priority
);
}

View File

@@ -24,21 +24,20 @@
void _Scheduler_priority_Yield( Thread_Control *thread )
{
Scheduler_priority_Per_thread *sched_info;
ISR_Level level;
Chain_Control *ready;
Scheduler_priority_Per_thread *sched_info_of_thread =
_Scheduler_priority_Get_scheduler_info( thread );
Chain_Control *ready_chain = sched_info_of_thread->ready_chain;
ISR_Level level;
sched_info = (Scheduler_priority_Per_thread *) thread->scheduler_info;
ready = sched_info->ready_chain;
_ISR_Disable( level );
if ( !_Chain_Has_only_one_node( ready ) ) {
if ( !_Chain_Has_only_one_node( ready_chain ) ) {
_Chain_Extract_unprotected( &thread->Object.Node );
_Chain_Append_unprotected( ready, &thread->Object.Node );
_Chain_Append_unprotected( ready_chain, &thread->Object.Node );
_ISR_Flash( level );
if ( _Thread_Is_heir( thread ) )
_Thread_Heir = (Thread_Control *) _Chain_First( ready );
_Thread_Heir = (Thread_Control *) _Chain_First( ready_chain );
_Thread_Dispatch_necessary = true;
}
else if ( !_Thread_Is_heir( thread ) )