1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Thread Queue Dequeue FIFO |
---|
5 | * @ingroup ScoreThreadQ |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2008. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/score/threadqimpl.h> |
---|
22 | #include <rtems/score/chainimpl.h> |
---|
23 | #include <rtems/score/isrlevel.h> |
---|
24 | #include <rtems/score/threadimpl.h> |
---|
25 | #include <rtems/score/watchdogimpl.h> |
---|
26 | |
---|
27 | Thread_Control *_Thread_queue_Dequeue_fifo( |
---|
28 | Thread_queue_Control *the_thread_queue |
---|
29 | ) |
---|
30 | { |
---|
31 | ISR_Level level; |
---|
32 | Thread_Control *the_thread; |
---|
33 | |
---|
34 | _ISR_Disable( level ); |
---|
35 | if ( !_Chain_Is_empty( &the_thread_queue->Queues.Fifo ) ) { |
---|
36 | |
---|
37 | the_thread = (Thread_Control *) |
---|
38 | _Chain_Get_first_unprotected( &the_thread_queue->Queues.Fifo ); |
---|
39 | |
---|
40 | the_thread->Wait.queue = NULL; |
---|
41 | if ( !_Watchdog_Is_active( &the_thread->Timer ) ) { |
---|
42 | _ISR_Enable( level ); |
---|
43 | _Thread_Unblock( the_thread ); |
---|
44 | } else { |
---|
45 | _Watchdog_Deactivate( &the_thread->Timer ); |
---|
46 | _ISR_Enable( level ); |
---|
47 | (void) _Watchdog_Remove( &the_thread->Timer ); |
---|
48 | _Thread_Unblock( the_thread ); |
---|
49 | } |
---|
50 | |
---|
51 | #if defined(RTEMS_MULTIPROCESSING) |
---|
52 | if ( !_Objects_Is_local_id( the_thread->Object.id ) ) |
---|
53 | _Thread_MP_Free_proxy( the_thread ); |
---|
54 | #endif |
---|
55 | |
---|
56 | return the_thread; |
---|
57 | } |
---|
58 | |
---|
59 | _ISR_Enable( level ); |
---|
60 | return NULL; |
---|
61 | } |
---|