OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [score/] [src/] [threadqenqueuefifo.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: threadqenqueuefifo.c,v 1.2 2001-09-27 11:59:34 chris Exp $
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_Enqueue_fifo
27
 *
28
 *  This routine blocks a thread, places it on a thread, and optionally
29
 *  starts a timeout timer.
30
 *
31
 *  Input parameters:
32
 *    the_thread_queue - pointer to threadq
33
 *    the_thread       - pointer to the thread to block
34
 *    timeout          - interval to wait
35
 *
36
 *  Output parameters: NONE
37
 *
38
 *  INTERRUPT LATENCY:
39
 *    only case
40
 */
41
 
42
void _Thread_queue_Enqueue_fifo (
43
  Thread_queue_Control *the_thread_queue,
44
  Thread_Control       *the_thread,
45
  Watchdog_Interval    timeout
46
)
47
{
48
  ISR_Level            level;
49
  Thread_queue_States  sync_state;
50
 
51
  _ISR_Disable( level );
52
 
53
  sync_state = the_thread_queue->sync_state;
54
  the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
55
 
56
  switch ( sync_state ) {
57
    case THREAD_QUEUE_SYNCHRONIZED:
58
      /*
59
       *  This should never happen.  It indicates that someone did not
60
       *  enter a thread queue critical section.
61
       */
62
      break;
63
 
64
    case THREAD_QUEUE_NOTHING_HAPPENED:
65
      _Chain_Append_unprotected(
66
        &the_thread_queue->Queues.Fifo,
67
        &the_thread->Object.Node
68
      );
69
      _ISR_Enable( level );
70
      return;
71
 
72
    case THREAD_QUEUE_TIMEOUT:
73
      the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status;
74
      _ISR_Enable( level );
75
      break;
76
 
77
    case THREAD_QUEUE_SATISFIED:
78
      if ( _Watchdog_Is_active( &the_thread->Timer ) ) {
79
        _Watchdog_Deactivate( &the_thread->Timer );
80
        _ISR_Enable( level );
81
        (void) _Watchdog_Remove( &the_thread->Timer );
82
      } else
83
        _ISR_Enable( level );
84
      break;
85
  }
86
 
87
  /*
88
   *  Global objects with thread queue's should not be operated on from an
89
   *  ISR.  But the sync code still must allow short timeouts to be processed
90
   *  correctly.
91
   */
92
 
93
  _Thread_Unblock( the_thread );
94
 
95
#if defined(RTEMS_MULTIPROCESSING)
96
  if ( !_Objects_Is_local_id( the_thread->Object.id ) )
97
    _Thread_MP_Free_proxy( the_thread );
98
#endif
99
 
100
}
101
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.