From 1506658c07ad05dd58e2781af4d3df67c90b9f70 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 8 Jan 2016 12:11:03 +0100 Subject: score: Simplify _Thread_Start() --- cpukit/posix/src/pthreadcreate.c | 2 +- cpukit/rtems/src/taskstart.c | 2 +- cpukit/score/include/rtems/score/threadimpl.h | 6 +----- cpukit/score/src/threadcreateidle.c | 31 +++++++++++++++++---------- cpukit/score/src/threadstart.c | 17 ++------------- 5 files changed, 25 insertions(+), 33 deletions(-) diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index 611477ec69..3185ab6553 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -228,7 +228,7 @@ int pthread_create( /* * POSIX threads are allocated and started in one operation. */ - status = _Thread_Start( the_thread, &entry, NULL ); + status = _Thread_Start( the_thread, &entry ); #if defined(RTEMS_DEBUG) /* diff --git a/cpukit/rtems/src/taskstart.c b/cpukit/rtems/src/taskstart.c index 39b3e9ca1d..416c2dfad2 100644 --- a/cpukit/rtems/src/taskstart.c +++ b/cpukit/rtems/src/taskstart.c @@ -64,7 +64,7 @@ rtems_status_code rtems_task_start( switch ( location ) { case OBJECTS_LOCAL: - successfully_started = _Thread_Start( the_thread, &entry, NULL ); + successfully_started = _Thread_Start( the_thread, &entry ); _Objects_Put( &the_thread->Object ); diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h index f212e23928..4177a972ae 100644 --- a/cpukit/score/include/rtems/score/threadimpl.h +++ b/cpukit/score/include/rtems/score/threadimpl.h @@ -187,14 +187,10 @@ bool _Thread_Initialize( * * @param the_thread The thread to be started. * @param entry The thread entry information. - * @param[in,out] cpu 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, - const Thread_Entry_information *entry, - Per_CPU_Control *cpu + const Thread_Entry_information *entry ); bool _Thread_Restart( diff --git a/cpukit/score/src/threadcreateidle.c b/cpukit/score/src/threadcreateidle.c index e9d12dc963..3430881f39 100644 --- a/cpukit/score/src/threadcreateidle.c +++ b/cpukit/score/src/threadcreateidle.c @@ -21,20 +21,14 @@ #include #include #include +#include #include static void _Thread_Create_idle_for_cpu( Per_CPU_Control *cpu ) { - Thread_Entry_information entry = { - .adaptor = _Thread_Entry_adaptor_idle, - .Kinds = { - .Idle = { - .entry = rtems_configuration_get_idle_task() - } - } - }; - Objects_Name name; - Thread_Control *idle; + Objects_Name name; + Thread_Control *idle; + const Scheduler_Control *scheduler; name.name_u32 = _Objects_Build_name( 'I', 'D', 'L', 'E' ); @@ -67,7 +61,22 @@ static void _Thread_Create_idle_for_cpu( Per_CPU_Control *cpu ) cpu->heir = cpu->executing = idle; - _Thread_Start( idle, &entry, cpu ); + idle->Start.Entry.adaptor = _Thread_Entry_adaptor_idle; + idle->Start.Entry.Kinds.Idle.entry = rtems_configuration_get_idle_task(); + + _Thread_Load_environment( idle ); + + scheduler = _Scheduler_Get_by_CPU( cpu ); + +#if defined(RTEMS_SMP) + if (scheduler == NULL) { + return; + } +#endif + + idle->current_state = STATES_READY; + _Scheduler_Start_idle( scheduler, idle, cpu ); + _User_extensions_Thread_start( idle ); } void _Thread_Create_idle( void ) diff --git a/cpukit/score/src/threadstart.c b/cpukit/score/src/threadstart.c index 97399ba524..0cdf2bc85a 100644 --- a/cpukit/score/src/threadstart.c +++ b/cpukit/score/src/threadstart.c @@ -21,30 +21,17 @@ #include #include -#include #include bool _Thread_Start( Thread_Control *the_thread, - const Thread_Entry_information *entry, - Per_CPU_Control *cpu + const Thread_Entry_information *entry ) { if ( _States_Is_dormant( the_thread->current_state ) ) { the_thread->Start.Entry = *entry; _Thread_Load_environment( the_thread ); - - if ( cpu == NULL ) { - _Thread_Ready( the_thread ); - } else { - const Scheduler_Control *scheduler = _Scheduler_Get_by_CPU( cpu ); - - if ( scheduler != NULL ) { - the_thread->current_state = STATES_READY; - _Scheduler_Start_idle( scheduler, the_thread, cpu ); - } - } - + _Thread_Ready( the_thread ); _User_extensions_Thread_start( the_thread ); return true; -- cgit v1.2.3