mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 13:17:45 +08:00
score: Simplify _Thread_Start()
This commit is contained in:
@@ -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)
|
||||
/*
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -21,20 +21,14 @@
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
#include <rtems/score/stackimpl.h>
|
||||
#include <rtems/score/userextimpl.h>
|
||||
#include <rtems/config.h>
|
||||
|
||||
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 )
|
||||
|
||||
@@ -21,30 +21,17 @@
|
||||
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/isrlevel.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
#include <rtems/score/userextimpl.h>
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user