From 08fe84b5d7072b7809581b1a25954a3b221497a5 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 22 Apr 2015 10:06:05 +0200 Subject: score: Generalize _Event_Timeout() Add a thread wait timeout code. Replace _Event_Timeout() with a general purpose _Thread_Timeout() watchdog handler. Update #2273. --- cpukit/rtems/Makefile.am | 1 - cpukit/rtems/src/eventseize.c | 8 ++++- cpukit/rtems/src/eventtimeout.c | 70 ----------------------------------------- 3 files changed, 7 insertions(+), 72 deletions(-) delete mode 100644 cpukit/rtems/src/eventtimeout.c (limited to 'cpukit/rtems') diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am index 5e6f2eafa0..084b39f8b3 100644 --- a/cpukit/rtems/Makefile.am +++ b/cpukit/rtems/Makefile.am @@ -210,7 +210,6 @@ librtems_a_SOURCES += src/eventreceive.c librtems_a_SOURCES += src/eventseize.c librtems_a_SOURCES += src/eventsend.c librtems_a_SOURCES += src/eventsurrender.c -librtems_a_SOURCES += src/eventtimeout.c librtems_a_SOURCES += src/systemeventsend.c librtems_a_SOURCES += src/systemeventreceive.c diff --git a/cpukit/rtems/src/eventseize.c b/cpukit/rtems/src/eventseize.c index 36b1964820..6611a8d6f6 100644 --- a/cpukit/rtems/src/eventseize.c +++ b/cpukit/rtems/src/eventseize.c @@ -89,7 +89,13 @@ void _Event_Seize( _Giant_Acquire( cpu_self ); if ( ticks ) { - _Watchdog_Initialize( &executing->Timer, _Event_Timeout, 0, executing ); + _Thread_Wait_set_timeout_code( executing, RTEMS_TIMEOUT ); + _Watchdog_Initialize( + &executing->Timer, + _Thread_Timeout, + 0, + executing + ); _Watchdog_Insert_ticks( &executing->Timer, ticks ); } diff --git a/cpukit/rtems/src/eventtimeout.c b/cpukit/rtems/src/eventtimeout.c deleted file mode 100644 index 5db118b183..0000000000 --- a/cpukit/rtems/src/eventtimeout.c +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file - * - * @brief Timeout Event - * @ingroup ClassicEvent - */ - -/* - * COPYRIGHT (c) 1989-2008. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#if HAVE_CONFIG_H - #include "config.h" -#endif - -#include -#include - -void _Event_Timeout( - Objects_Id id, - void *arg -) -{ - Thread_Control *the_thread; - ISR_lock_Context lock_context; - Thread_Wait_flags wait_flags; - Thread_Wait_flags wait_class; - Thread_Wait_flags intend_to_block; - Thread_Wait_flags blocked; - bool success; - bool unblock; - - the_thread = arg; - _Thread_Lock_acquire_default( the_thread, &lock_context ); - - 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_READY_AGAIN - ); - - 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_READY_AGAIN - ); - unblock = true; - } else { - unblock = false; - } - - _Thread_Lock_release_default( the_thread, &lock_context ); - - if ( unblock ) { - _Thread_Unblock( the_thread ); - } -} -- cgit v1.2.3