1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Thread queue Enqueue 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.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/score/chainimpl.h> |
---|
23 | #include <rtems/score/isr.h> |
---|
24 | #include <rtems/score/object.h> |
---|
25 | #include <rtems/score/states.h> |
---|
26 | #include <rtems/score/thread.h> |
---|
27 | #include <rtems/score/threadq.h> |
---|
28 | #include <rtems/score/tqdata.h> |
---|
29 | |
---|
30 | Thread_blocking_operation_States _Thread_queue_Enqueue_fifo ( |
---|
31 | Thread_queue_Control *the_thread_queue, |
---|
32 | Thread_Control *the_thread, |
---|
33 | ISR_Level *level_p |
---|
34 | ) |
---|
35 | { |
---|
36 | Thread_blocking_operation_States sync_state; |
---|
37 | ISR_Level level; |
---|
38 | |
---|
39 | _ISR_Disable( level ); |
---|
40 | |
---|
41 | sync_state = the_thread_queue->sync_state; |
---|
42 | the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED; |
---|
43 | if (sync_state == THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED) { |
---|
44 | _Chain_Append_unprotected( |
---|
45 | &the_thread_queue->Queues.Fifo, |
---|
46 | &the_thread->Object.Node |
---|
47 | ); |
---|
48 | the_thread->Wait.queue = the_thread_queue; |
---|
49 | |
---|
50 | the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED; |
---|
51 | _ISR_Enable( level ); |
---|
52 | return THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED; |
---|
53 | } |
---|
54 | |
---|
55 | /* |
---|
56 | * An interrupt completed the thread's blocking request. |
---|
57 | * For example, the blocking thread could have been given |
---|
58 | * the mutex by an ISR or timed out. |
---|
59 | * |
---|
60 | * WARNING! Returning with interrupts disabled! |
---|
61 | */ |
---|
62 | *level_p = level; |
---|
63 | return sync_state; |
---|
64 | } |
---|