diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-13 07:04:43 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 07:49:38 +0200 |
commit | 938839077741d2eac82d9d86705c16e0b9de8379 (patch) | |
tree | cf426c86ed7751264c0ff3db600627cbbfda99ff /cpukit/rtems | |
parent | score: Add _Thread_Dispatch_disable_with_CPU() (diff) | |
download | rtems-938839077741d2eac82d9d86705c16e0b9de8379.tar.bz2 |
score: Split _Thread_Restart()
Split _Thread_Restart() into _Thread_Restart_self() and
_Thread_Restart_other(). Move content of existing
_Thread_Restart_self() into new _Thread_Restart_self(). Avoid Giant
lock for thread restart. _Thread_Restart_self() is a no-return function
and used by _Thread_Global_construction().
Update #2555.
Update #2626.
Diffstat (limited to 'cpukit/rtems')
-rw-r--r-- | cpukit/rtems/src/taskrestart.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/cpukit/rtems/src/taskrestart.c b/cpukit/rtems/src/taskrestart.c index 8aa7c73d9a..6e4ad96545 100644 --- a/cpukit/rtems/src/taskrestart.c +++ b/cpukit/rtems/src/taskrestart.c @@ -26,32 +26,32 @@ rtems_status_code rtems_task_restart( uint32_t argument ) { - Thread_Control *the_thread; - Objects_Locations location; - Thread_Entry_information entry; - - the_thread = _Thread_Get( id, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: - entry = the_thread->Start.Entry; - entry.Kinds.Numeric.argument = argument; - if ( _Thread_Restart( the_thread, _Thread_Executing, &entry ) ) { - _Objects_Put( &the_thread->Object ); - return RTEMS_SUCCESSFUL; - } - _Objects_Put( &the_thread->Object ); - return RTEMS_INCORRECT_STATE; + Thread_Control *the_thread; + ISR_lock_Context lock_context; + Thread_Entry_information entry; + bool ok; + 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; + entry = the_thread->Start.Entry; + entry.Kinds.Numeric.argument = argument; + + if ( the_thread == _Thread_Executing ) { + _Thread_Restart_self( the_thread, &entry, &lock_context ); + RTEMS_UNREACHABLE(); + } + + ok = _Thread_Restart_other( the_thread, &entry, &lock_context ); + + return ok ? RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE; } |