source: rtems/cpukit/score/src/threadqenqueue.c @ 37c7bfcb

4.104.114.84.95
Last change on this file since 37c7bfcb was 96d0b64, checked in by Joel Sherrill <joel.sherrill@…>, on 03/05/07 at 21:01:40

2007-03-05 Joel Sherrill <joel@…>

PR 1222/cpukit

  • score/Makefile.am, score/include/rtems/score/coremutex.h, score/include/rtems/score/threadq.h, score/inline/rtems/score/coremutex.inl, score/src/coremsgsubmit.c, score/src/coremutexsurrender.c, score/src/threadchangepriority.c, score/src/threadclearstate.c, score/src/threadhandler.c, score/src/threadinitialize.c, score/src/threadqdequeuefifo.c, score/src/threadqdequeuepriority.c, score/src/threadqenqueue.c, score/src/threadqenqueuefifo.c, score/src/threadqenqueuepriority.c, score/src/threadqextractfifo.c, score/src/threadqextractpriority.c, score/src/threadsetstate.c: Enhance so that when the prioirity of a thread that is blocked on a priority based thread queue is changed, that its placement in the queue is reevaluated based upon the new priority. This enhancement includes modifications to the SuperCore? as well as new test cases.
  • score/src/threadqrequeue.c: New file.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  Thread Queue Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-2006.
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#if defined(RTEMS_MULTIPROCESSING)
28#include <rtems/score/mpci.h>
29#endif
30
31/*PAGE
32 *
33 *  _Thread_queue_Enqueue_with_handler
34 *
35 *  This routine blocks a thread, places it on a thread, and optionally
36 *  starts a timeout timer.
37 *
38 *  Input parameters:
39 *    the_thread_queue - pointer to threadq
40 *    timeout          - interval to wait
41 *
42 *  Output parameters: NONE
43 *
44 *  INTERRUPT LATENCY:
45 *    only case
46 */
47
48void _Thread_queue_Enqueue_with_handler(
49  Thread_queue_Control         *the_thread_queue,
50  Watchdog_Interval             timeout,
51  Thread_queue_Timeout_callout  handler
52)
53{
54  Thread_Control *the_thread;
55
56  the_thread = _Thread_Executing;
57
58#if defined(RTEMS_MULTIPROCESSING)
59  if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet )
60    the_thread = _Thread_MP_Allocate_proxy( the_thread_queue->state );
61  else
62#endif
63  /*
64   *  Set the blocking state for this thread queue in the thread.
65   */
66  _Thread_Set_state( the_thread, the_thread_queue->state );
67
68  /*
69   *  If the thread wants to timeout, then schedule its timer.
70   */
71  if ( timeout ) {
72    _Watchdog_Initialize(
73       &the_thread->Timer,
74       handler,
75       the_thread->Object.id,
76       NULL
77    );
78
79    _Watchdog_Insert_ticks( &the_thread->Timer, timeout );
80  }
81
82  /*
83   *  Now enqueue the thread per the discipline for this thread queue.
84   */
85  switch( the_thread_queue->discipline ) {
86    case THREAD_QUEUE_DISCIPLINE_FIFO:
87      _Thread_queue_Enqueue_fifo( the_thread_queue, the_thread );
88      break;
89    case THREAD_QUEUE_DISCIPLINE_PRIORITY:
90      _Thread_queue_Enqueue_priority( the_thread_queue, the_thread );
91      break;
92  }
93}
Note: See TracBrowser for help on using the repository browser.