source: rtems/cpukit/score/src/threadqenqueuefifo.c @ f172fc89

4.104.114.84.95
Last change on this file since f172fc89 was 83df49f, checked in by Joel Sherrill <joel.sherrill@…>, on 07/11/06 at 21:05:12

2006-07-11 Joel Sherrill <joel@…>

PR 1124/rtems

  • score/include/rtems/score/threadq.h, score/src/coremutexseize.c, score/src/coremutexsurrender.c, score/src/threadqenqueue.c, score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c: The placement of the changing a thread's priority when using priority ceiling should be on the successful transfer of the mutex -- not when the thread tries to acquire. Plus the lack of a dispatch disable point lead to the potential for a thread timing out and already having inherited the ceiling priority.
  • Property mode set to 100644
File size: 2.4 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.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/chain.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/object.h>
23#include <rtems/score/states.h>
24#include <rtems/score/thread.h>
25#include <rtems/score/threadq.h>
26#include <rtems/score/tqdata.h>
27
28/*PAGE
29 *
30 *  _Thread_queue_Enqueue_fifo
31 *
32 *  This routine places a blocked thread on a FIFO thread queue.
33 *
34 *  Input parameters:
35 *    the_thread_queue - pointer to threadq
36 *    the_thread       - pointer to the thread to block
37 *
38 *  Output parameters: NONE
39 *
40 *  INTERRUPT LATENCY:
41 *    only case
42 */
43
44void _Thread_queue_Enqueue_fifo (
45  Thread_queue_Control *the_thread_queue,
46  Thread_Control       *the_thread
47)
48{
49  ISR_Level            level;
50  Thread_queue_States  sync_state;
51
52  _ISR_Disable( level );
53
54  sync_state = the_thread_queue->sync_state;
55  the_thread_queue->sync_state = THREAD_QUEUE_SYNCHRONIZED;
56
57  switch ( sync_state ) {
58    case THREAD_QUEUE_SYNCHRONIZED:
59      /*
60       *  This should never happen.  It indicates that someone did not
61       *  enter a thread queue critical section.
62       */
63      break;
64
65    case THREAD_QUEUE_NOTHING_HAPPENED:
66      _Chain_Append_unprotected(
67        &the_thread_queue->Queues.Fifo,
68        &the_thread->Object.Node
69      );
70      _ISR_Enable( level );
71      return;
72
73    case THREAD_QUEUE_TIMEOUT:
74      the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status;
75      _ISR_Enable( level );
76      break;
77
78    case THREAD_QUEUE_SATISFIED:
79      if ( _Watchdog_Is_active( &the_thread->Timer ) ) {
80        _Watchdog_Deactivate( &the_thread->Timer );
81        _ISR_Enable( level );
82        (void) _Watchdog_Remove( &the_thread->Timer );
83      } else
84        _ISR_Enable( level );
85      break;
86  }
87
88  /*
89   *  Global objects with thread queue's should not be operated on from an
90   *  ISR.  But the sync code still must allow short timeouts to be processed
91   *  correctly.
92   */
93
94  _Thread_Unblock( the_thread );
95
96#if defined(RTEMS_MULTIPROCESSING)
97  if ( !_Objects_Is_local_id( the_thread->Object.id ) )
98    _Thread_MP_Free_proxy( the_thread );
99#endif
100
101}
Note: See TracBrowser for help on using the repository browser.