[rtems commit] score: Add _Thread_Set_state_locked()

Sebastian Huber sebh at rtems.org
Fri May 20 05:58:02 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri May 13 07:12:10 2016 +0200

score: Add _Thread_Set_state_locked()

This makes it possible to do thread state and thread life changes
together under protection of the thread state lock.

Update #2555.
Update #2626.

---

 cpukit/score/include/rtems/score/threadimpl.h |  5 +++++
 cpukit/score/src/threadsetstate.c             | 23 +++++++++++++++++------
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/cpukit/score/include/rtems/score/threadimpl.h b/cpukit/score/include/rtems/score/threadimpl.h
index eee896d..09e3382 100644
--- a/cpukit/score/include/rtems/score/threadimpl.h
+++ b/cpukit/score/include/rtems/score/threadimpl.h
@@ -247,6 +247,11 @@ States_Control _Thread_Clear_state(
   States_Control  state
 );
 
+States_Control _Thread_Set_state_locked(
+  Thread_Control *the_thread,
+  States_Control  state
+);
+
 /**
  * @brief Sets the specified thread state.
  *
diff --git a/cpukit/score/src/threadsetstate.c b/cpukit/score/src/threadsetstate.c
index 3aaa463..c863d17 100644
--- a/cpukit/score/src/threadsetstate.c
+++ b/cpukit/score/src/threadsetstate.c
@@ -25,18 +25,16 @@
 #include <rtems/score/assert.h>
 #include <rtems/score/schedulerimpl.h>
 
-States_Control _Thread_Set_state(
+States_Control _Thread_Set_state_locked(
   Thread_Control *the_thread,
   States_Control  state
 )
 {
-  ISR_lock_Context lock_context;
-  States_Control   previous_state;
-  States_Control   next_state;
+  States_Control previous_state;
+  States_Control next_state;
 
   _Assert( state != 0 );
-
-  _Thread_State_acquire( the_thread, &lock_context );
+  _Assert( _Thread_State_is_owner( the_thread ) );
 
   previous_state = the_thread->current_state;
   next_state = _States_Set( state, previous_state);
@@ -46,6 +44,19 @@ States_Control _Thread_Set_state(
     _Scheduler_Block( the_thread );
   }
 
+  return previous_state;
+}
+
+States_Control _Thread_Set_state(
+  Thread_Control *the_thread,
+  States_Control  state
+)
+{
+  ISR_lock_Context lock_context;
+  States_Control   previous_state;
+
+  _Thread_State_acquire( the_thread, &lock_context );
+  previous_state = _Thread_Set_state_locked( the_thread, state );
   _Thread_State_release( the_thread, &lock_context );
 
   return previous_state;




More information about the vc mailing list