source: rtems/cpukit/score/src/threadqenqueuefifo.c @ 6e93dc4a

4.115
Last change on this file since 6e93dc4a was 6e93dc4a, checked in by Sebastian Huber <sebastian.huber@…>, on 07/22/13 at 08:49:19

score: Create chain implementation header

Move implementation specific parts of chain.h and chain.inl into new
header file chainimpl.h. The chain.h contains now only the application
visible API.

  • Property mode set to 100644
File size: 1.7 KB
Line 
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
30Thread_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}
Note: See TracBrowser for help on using the repository browser.