scheduler: Add start idle thread operation

Add and use _Scheduler_Start_idle().
This commit is contained in:
Sebastian Huber
2013-06-06 15:28:41 +02:00
parent 477259c4ed
commit 1ccb64e18f
13 changed files with 97 additions and 15 deletions

View File

@@ -203,7 +203,8 @@ int pthread_create(
THREAD_START_POINTER,
start_routine,
arg,
0 /* unused */
0, /* unused */
NULL
);
#if defined(RTEMS_DEBUG)

View File

@@ -58,6 +58,7 @@ rtems_status_code rtems_task_start(
{
register Thread_Control *the_thread;
Objects_Locations location;
bool successfully_started;
if ( entry_point == NULL )
return RTEMS_INVALID_ADDRESS;
@@ -66,13 +67,22 @@ rtems_status_code rtems_task_start(
switch ( location ) {
case OBJECTS_LOCAL:
if ( _Thread_Start(
the_thread, THREAD_START_NUMERIC, entry_point, NULL, argument ) ) {
_Objects_Put( &the_thread->Object );
return RTEMS_SUCCESSFUL;
}
successfully_started = _Thread_Start(
the_thread,
THREAD_START_NUMERIC,
entry_point,
NULL,
argument,
NULL
);
_Objects_Put( &the_thread->Object );
return RTEMS_INCORRECT_STATE;
if ( successfully_started ) {
return RTEMS_SUCCESSFUL;
} else {
return RTEMS_INCORRECT_STATE;
}
#if defined(RTEMS_MULTIPROCESSING)
case OBJECTS_REMOTE:

View File

@@ -197,6 +197,7 @@ libscore_a_SOURCES += src/objectallocate.c src/objectclose.c \
## SCHEDULER_C_FILES
libscore_a_SOURCES += src/scheduler.c
libscore_a_SOURCES += src/schedulerdefaultstartidle.c
## SCHEDULERPRIORITY_C_FILES
libscore_a_SOURCES += src/schedulerpriority.c \

View File

@@ -89,6 +89,12 @@ typedef struct {
/** perform scheduler update actions required at each clock tick */
void ( *tick )(void);
/**
* @brief Starts the idle thread for a particular processor.
*
* @see _Scheduler_Start_idle().
*/
void ( *start_idle )( Thread_Control *thread, Per_CPU_Control *processor );
} Scheduler_Operations;
/**
@@ -139,6 +145,17 @@ extern Scheduler_Control _Scheduler;
*/
void _Scheduler_Handler_initialization( void );
/**
* @brief Unblocks the thread.
*
* @param[in/out] thread An idle thread.
* @param[in] processor This parameter is unused.
*/
void _Scheduler_default_Start_idle(
Thread_Control *thread,
Per_CPU_Control *processor
);
#ifndef __RTEMS_APPLICATION__
#include <rtems/score/scheduler.inl>
#endif

View File

@@ -60,7 +60,8 @@ extern "C" {
_Scheduler_EDF_Extract, /* extract entry point */ \
_Scheduler_EDF_Priority_compare, /* compares two priorities */ \
_Scheduler_CBS_Release_job, /* new period of task */ \
_Scheduler_priority_Tick /* tick entry point */ \
_Scheduler_priority_Tick, /* tick entry point */ \
_Scheduler_default_Start_idle /* start idle entry point */ \
}
/* Return values for CBS server. */

View File

@@ -53,7 +53,8 @@ extern "C" {
_Scheduler_EDF_Extract, /* extract entry point */ \
_Scheduler_EDF_Priority_compare, /* compares two priorities */ \
_Scheduler_EDF_Release_job, /* new period of task */ \
_Scheduler_priority_Tick /* tick entry point */ \
_Scheduler_priority_Tick, /* tick entry point */ \
_Scheduler_default_Start_idle /* start idle entry point */ \
}
/**

View File

@@ -52,7 +52,8 @@ extern "C" {
_Scheduler_priority_Extract, /* extract entry point */ \
_Scheduler_priority_Priority_compare, /* compares two priorities */ \
_Scheduler_priority_Release_job, /* new period of task */ \
_Scheduler_priority_Tick /* tick entry point */ \
_Scheduler_priority_Tick, /* tick entry point */ \
_Scheduler_default_Start_idle /* start idle entry point */ \
}
/**

View File

@@ -50,7 +50,8 @@ extern "C" {
_Scheduler_simple_Extract, /* extract entry point */ \
_Scheduler_priority_Priority_compare, /* compares two priorities */ \
_Scheduler_priority_Release_job, /* new period of task */ \
_Scheduler_priority_Tick /* tick entry point */ \
_Scheduler_priority_Tick, /* tick entry point */ \
_Scheduler_default_Start_idle /* start idle entry point */ \
}
/**

View File

@@ -571,13 +571,17 @@ bool _Thread_Initialize(
* @param entry_point
* @param pointer_argument
* @param numeric_argument
* @param[in/out] processor The processor if used to start an idle thread
* during system initialization. Must be set to @c NULL to start a normal
* thread.
*/
bool _Thread_Start(
Thread_Control *the_thread,
Thread_Start_types the_prototype,
void *entry_point,
void *pointer_argument,
Thread_Entry_numeric_type numeric_argument
Thread_Entry_numeric_type numeric_argument,
Per_CPU_Control *processor
);
/**

View File

@@ -208,6 +208,22 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Tick( void )
_Scheduler.Operations.tick();
}
/**
* @brief Starts the idle thread for a particular processor.
*
* @param[in/out] thread The idle thread for the processor.
* @parma[in/out] processor The processor for the idle thread.
*
* @see _Thread_Create_idle().
*/
RTEMS_INLINE_ROUTINE void _Scheduler_Start_idle(
Thread_Control *thread,
Per_CPU_Control *processor
)
{
( *_Scheduler.Operations.start_idle )( thread, processor );
}
/** @} */
#endif

View File

@@ -0,0 +1,22 @@
/*
* Copyright (c) 2013 embedded brains GmbH
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems/score/scheduler.h>
void _Scheduler_default_Start_idle(
Thread_Control *thread,
Per_CPU_Control *processor
)
{
(void) processor;
_Scheduler_Unblock( thread );
}

View File

@@ -73,7 +73,8 @@ static void _Thread_Create_idle_for_cpu( Per_CPU_Control *per_cpu )
THREAD_START_NUMERIC,
rtems_configuration_get_idle_task(),
NULL,
0
0,
per_cpu
);
}

View File

@@ -38,7 +38,8 @@ bool _Thread_Start(
Thread_Start_types the_prototype,
void *entry_point,
void *pointer_argument,
Thread_Entry_numeric_type numeric_argument
Thread_Entry_numeric_type numeric_argument,
Per_CPU_Control *processor
)
{
if ( _States_Is_dormant( the_thread->current_state ) ) {
@@ -51,7 +52,12 @@ bool _Thread_Start(
_Thread_Load_environment( the_thread );
_Thread_Ready( the_thread );
if ( processor == NULL ) {
_Thread_Ready( the_thread );
} else {
the_thread->current_state = STATES_READY;
_Scheduler_Start_idle( the_thread, processor );
}
_User_extensions_Thread_start( the_thread );