summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/threadclearstate.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-03-26 21:45:20 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-08 11:48:12 +0200
commit342708b9834096a2c8a9ad604626c82da6fb956c (patch)
tree95fd2faaeff1cb270d1df8e469145357139d851b /cpukit/score/src/threadclearstate.c
parentscore: Simplify _Thread_Set_state() (diff)
downloadrtems-342708b9834096a2c8a9ad604626c82da6fb956c.tar.bz2
score: Return prev state in thread state set/clear
Diffstat (limited to 'cpukit/score/src/threadclearstate.c')
-rw-r--r--cpukit/score/src/threadclearstate.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/cpukit/score/src/threadclearstate.c b/cpukit/score/src/threadclearstate.c
index c60fb8fc41..ae54e3aac1 100644
--- a/cpukit/score/src/threadclearstate.c
+++ b/cpukit/score/src/threadclearstate.c
@@ -19,27 +19,35 @@
#endif
#include <rtems/score/threadimpl.h>
+#include <rtems/score/assert.h>
#include <rtems/score/schedulerimpl.h>
-void _Thread_Clear_state(
+States_Control _Thread_Clear_state(
Thread_Control *the_thread,
States_Control state
)
{
ISR_lock_Context lock_context;
- States_Control current_state;
+ States_Control previous_state;
+
+ _Assert( state != 0 );
_Scheduler_Acquire( the_thread, &lock_context );
- current_state = the_thread->current_state;
- if ( current_state & state ) {
- current_state =
- the_thread->current_state = _States_Clear( state, current_state );
+ previous_state = the_thread->current_state;
+
+ if ( ( previous_state & state ) != 0 ) {
+ States_Control next_state;
- if ( _States_Is_ready( current_state ) ) {
+ next_state = _States_Clear( state, previous_state );
+ the_thread->current_state = next_state;
+
+ if ( _States_Is_ready( next_state ) ) {
_Scheduler_Unblock( the_thread );
}
}
_Scheduler_Release( the_thread, &lock_context );
+
+ return previous_state;
}