[rtems commit] rtems: Avoid Giant lock rtems_task_is_suspended()

Sebastian Huber sebh at rtems.org
Thu May 12 11:34:29 UTC 2016


Module:    rtems
Branch:    master
Commit:    11c66437e750e6f8c464a96476c5f5221c1808a6
Changeset: http://git.rtems.org/rtems/commit/?id=11c66437e750e6f8c464a96476c5f5221c1808a6

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed May 11 10:27:37 2016 +0200

rtems: Avoid Giant lock rtems_task_is_suspended()

Update #2555.

---

 cpukit/rtems/src/taskissuspended.c | 48 +++++++++++---------------------------
 1 file changed, 13 insertions(+), 35 deletions(-)

diff --git a/cpukit/rtems/src/taskissuspended.c b/cpukit/rtems/src/taskissuspended.c
index 1414052..467281d 100644
--- a/cpukit/rtems/src/taskissuspended.c
+++ b/cpukit/rtems/src/taskissuspended.c
@@ -21,48 +21,26 @@
 #include <rtems/rtems/tasks.h>
 #include <rtems/score/threadimpl.h>
 
-/*
- *  rtems_task_is_suspended
- *
- *  This directive returns a status indicating whether or not
- *  the specified task is suspended.
- *
- *  Input parameters:
- *    id - thread id
- *
- *  Output parameters:
- *    RTEMS_SUCCESSFUL        - if successful and not suspended
- *    RTEMS_ALREADY_SUSPENDED - if successful and suspended
- *    error code              - if unsuccessful
- */
-
-rtems_status_code rtems_task_is_suspended(
-  rtems_id id
-)
+rtems_status_code rtems_task_is_suspended( rtems_id id )
 {
-  Thread_Control          *the_thread;
-  Objects_Locations        location;
-
-  the_thread = _Thread_Get( id, &location );
-  switch ( location ) {
+  Thread_Control   *the_thread;
+  ISR_lock_Context  lock_context;
+  States_Control    current_state;
 
-    case OBJECTS_LOCAL:
-      if ( !_States_Is_suspended( the_thread->current_state ) ) {
-        _Objects_Put( &the_thread->Object );
-        return RTEMS_SUCCESSFUL;
-      }
-      _Objects_Put( &the_thread->Object );
-      return RTEMS_ALREADY_SUSPENDED;
+  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;
+  current_state = the_thread->current_state;
+  _ISR_lock_ISR_enable( &lock_context);
+  return _States_Is_suspended( current_state ) ?
+    RTEMS_ALREADY_SUSPENDED : RTEMS_SUCCESSFUL;
 }



More information about the vc mailing list