summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/eventtimeout.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-20 09:45:10 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2015-04-21 08:25:32 +0200
commit1041de1ab071d126148f0c02e5da0db637001f1c (patch)
tree07c077b044a14d2abca32e8f9a453eec1141431e /cpukit/rtems/src/eventtimeout.c
parentscore: Modify _Thread_Dispatch_disable_critical() (diff)
downloadrtems-1041de1ab071d126148f0c02e5da0db637001f1c.tar.bz2
score: Add _Thread_Get_interrupt_disable()
Remove _Thread_Acquire() and _Thread_Acquire_for_executing(). Add utility functions for the default thread lock. Use the default thread lock for the RTEMS events. There is no need to disable thread dispatching and a Giant acquire in _Event_Timeout() since this was already done by the caller. Update #2273.
Diffstat (limited to 'cpukit/rtems/src/eventtimeout.c')
-rw-r--r--cpukit/rtems/src/eventtimeout.c74
1 files changed, 27 insertions, 47 deletions
diff --git a/cpukit/rtems/src/eventtimeout.c b/cpukit/rtems/src/eventtimeout.c
index 295f0c5b5f..9c091748c0 100644
--- a/cpukit/rtems/src/eventtimeout.c
+++ b/cpukit/rtems/src/eventtimeout.c
@@ -27,7 +27,6 @@ void _Event_Timeout(
)
{
Thread_Control *the_thread;
- Objects_Locations location;
ISR_lock_Context lock_context;
Thread_Wait_flags wait_flags;
Thread_Wait_flags wait_class;
@@ -36,55 +35,36 @@ void _Event_Timeout(
bool success;
bool unblock;
- the_thread = _Thread_Acquire( id, &location, &lock_context );
- switch ( location ) {
- case OBJECTS_LOCAL:
- wait_flags = _Thread_Wait_flags_get( the_thread );
- wait_class = wait_flags & THREAD_WAIT_CLASS_MASK;
- intend_to_block = wait_class | THREAD_WAIT_STATE_INTEND_TO_BLOCK;
- blocked = wait_class | THREAD_WAIT_STATE_BLOCKED;
- success = _Thread_Wait_flags_try_change_critical(
- the_thread,
- intend_to_block,
- wait_class | THREAD_WAIT_STATE_INTERRUPT_TIMEOUT
- );
+ the_thread = arg;
+ _Thread_Lock_acquire_default( the_thread, &lock_context );
- if ( success ) {
- the_thread->Wait.return_code = RTEMS_TIMEOUT;
- unblock = false;
- } else if ( _Thread_Wait_flags_get( the_thread ) == blocked ) {
- the_thread->Wait.return_code = RTEMS_TIMEOUT;
- _Thread_Wait_flags_set(
- the_thread,
- wait_class | THREAD_WAIT_STATE_TIMEOUT
- );
- unblock = true;
- } else {
- unblock = false;
- }
+ wait_flags = _Thread_Wait_flags_get( the_thread );
+ wait_class = wait_flags & THREAD_WAIT_CLASS_MASK;
+ intend_to_block = wait_class | THREAD_WAIT_STATE_INTEND_TO_BLOCK;
+ blocked = wait_class | THREAD_WAIT_STATE_BLOCKED;
+ success = _Thread_Wait_flags_try_change_critical(
+ the_thread,
+ intend_to_block,
+ wait_class | THREAD_WAIT_STATE_INTERRUPT_TIMEOUT
+ );
- if ( unblock ) {
- Per_CPU_Control *cpu_self;
-
- cpu_self = _Objects_Release_and_thread_dispatch_disable(
- &the_thread->Object,
- &lock_context
- );
- _Giant_Acquire( cpu_self );
-
- _Thread_Unblock( the_thread );
+ if ( success ) {
+ the_thread->Wait.return_code = RTEMS_TIMEOUT;
+ unblock = false;
+ } else if ( _Thread_Wait_flags_get( the_thread ) == blocked ) {
+ the_thread->Wait.return_code = RTEMS_TIMEOUT;
+ _Thread_Wait_flags_set(
+ the_thread,
+ wait_class | THREAD_WAIT_STATE_TIMEOUT
+ );
+ unblock = true;
+ } else {
+ unblock = false;
+ }
- _Giant_Release( cpu_self );
- _Thread_Dispatch_enable( cpu_self );
- } else {
- _Objects_Release_and_ISR_enable( &the_thread->Object, &lock_context );
- }
+ _Thread_Lock_release_default( the_thread, &lock_context );
- break;
-#if defined(RTEMS_MULTIPROCESSING)
- case OBJECTS_REMOTE: /* impossible */
-#endif
- case OBJECTS_ERROR:
- break;
+ if ( unblock ) {
+ _Thread_Unblock( the_thread );
}
}