source: rtems/cpukit/score/src/threadqdequeuefifo.c @ 2728d9cf

4.104.114.84.95
Last change on this file since 2728d9cf was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  Thread Queue Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/score/chain.h>
17#include <rtems/score/isr.h>
18#include <rtems/score/object.h>
19#include <rtems/score/states.h>
20#include <rtems/score/thread.h>
21#include <rtems/score/threadq.h>
22#include <rtems/score/tqdata.h>
23
24/*PAGE
25 *
26 *  _Thread_queue_Dequeue_fifo
27 *
28 *  This routine removes a thread from the specified threadq.
29 *
30 *  Input parameters:
31 *    the_thread_queue - pointer to threadq
32 *
33 *  Output parameters:
34 *    returns - thread dequeued or NULL
35 *
36 *  INTERRUPT LATENCY:
37 *    check sync
38 *    FIFO
39 */
40
41Thread_Control *_Thread_queue_Dequeue_fifo(
42  Thread_queue_Control *the_thread_queue
43)
44{
45  ISR_Level              level;
46  Thread_Control *the_thread;
47
48  _ISR_Disable( level );
49  if ( !_Chain_Is_empty( &the_thread_queue->Queues.Fifo ) ) {
50
51    the_thread = (Thread_Control *)
52       _Chain_Get_first_unprotected( &the_thread_queue->Queues.Fifo );
53
54    if ( !_Watchdog_Is_active( &the_thread->Timer ) ) {
55      _ISR_Enable( level );
56      _Thread_Unblock( the_thread );
57    } else {
58      _Watchdog_Deactivate( &the_thread->Timer );
59      _ISR_Enable( level );
60      (void) _Watchdog_Remove( &the_thread->Timer );
61      _Thread_Unblock( the_thread );
62    }
63
64#if defined(RTEMS_MULTIPROCESSING)
65    if ( !_Objects_Is_local_id( the_thread->Object.id ) )
66      _Thread_MP_Free_proxy( the_thread );
67#endif
68
69    return the_thread;
70  }
71
72  switch ( the_thread_queue->sync_state ) {
73    case THREAD_QUEUE_SYNCHRONIZED:
74    case THREAD_QUEUE_SATISFIED:
75      _ISR_Enable( level );
76      return NULL;
77
78    case THREAD_QUEUE_NOTHING_HAPPENED:
79    case THREAD_QUEUE_TIMEOUT:
80      the_thread_queue->sync_state = THREAD_QUEUE_SATISFIED;
81      _ISR_Enable( level );
82      return _Thread_Executing;
83  }
84  return NULL;                /* this is only to prevent warnings */
85}
86
Note: See TracBrowser for help on using the repository browser.