From 33829ce155069462ba410d396da431386369ed08 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 13 May 2016 14:07:23 +0200 Subject: score: Avoid Giant lock for _Thread_Start() Update #2555. --- cpukit/rtems/src/taskstart.c | 58 +++++++++++--------------------------------- 1 file changed, 14 insertions(+), 44 deletions(-) (limited to 'cpukit/rtems/src/taskstart.c') diff --git a/cpukit/rtems/src/taskstart.c b/cpukit/rtems/src/taskstart.c index 416c2dfad2..172979bde3 100644 --- a/cpukit/rtems/src/taskstart.c +++ b/cpukit/rtems/src/taskstart.c @@ -21,27 +21,10 @@ #include #include -/* - * rtems_task_start - * - * This directive readies the thread identified by the "id" - * based on its current priorty, to await execution. A thread - * can be started only from the dormant state. - * - * Input parameters: - * id - thread id - * entry_point - start execution address of thread - * argument - thread argument - * - * Output parameters: - * RTEMS_SUCCESSFUL - if successful - * error code - if unsuccessful - */ - rtems_status_code rtems_task_start( - rtems_id id, - rtems_task_entry entry_point, - rtems_task_argument argument + rtems_id id, + rtems_task_entry entry_point, + rtems_task_argument argument ) { Thread_Entry_information entry = { @@ -53,36 +36,23 @@ rtems_status_code rtems_task_start( } } }; - Thread_Control *the_thread; - Objects_Locations location; - bool successfully_started; - - if ( entry_point == NULL ) - return RTEMS_INVALID_ADDRESS; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + bool ok; - the_thread = _Thread_Get( id, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - successfully_started = _Thread_Start( the_thread, &entry ); - - _Objects_Put( &the_thread->Object ); - - if ( successfully_started ) { - return RTEMS_SUCCESSFUL; - } else { - return RTEMS_INCORRECT_STATE; - } + the_thread = _Thread_Get_interrupt_disable( id, &lock_context ); + if ( the_thread == NULL ) { #if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: - _Thread_Dispatch(); + if ( _Thread_MP_Is_remote( id ) ) { return RTEMS_ILLEGAL_ON_REMOTE_OBJECT; + } #endif - case OBJECTS_ERROR: - break; + return RTEMS_INVALID_ID; } - return RTEMS_INVALID_ID; + ok = _Thread_Start( the_thread, &entry, &lock_context ); + + return ok ? RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE; } -- cgit v1.2.3