source: rtems/cpukit/score/src/threadqenqueue.c @ 749d64a

4.104.115
Last change on this file since 749d64a was b3836ce, checked in by Joel Sherrill <joel.sherrill@…>, on 09/05/08 at 21:54:20

2008-09-05 Joel Sherrill <joel.sherrill@…>

  • score/src/corebarrier.c, score/src/corebarrierrelease.c, score/src/corebarrierwait.c, score/src/coremsg.c, score/src/coremsgbroadcast.c, score/src/coremsgclose.c, score/src/coremsgflush.c, score/src/coremsgflushsupp.c, score/src/coremsgflushwait.c, score/src/coremsginsert.c, score/src/coremsgseize.c, score/src/coremsgsubmit.c, score/src/corerwlock.c, score/src/coresem.c, score/src/coresemflush.c, score/src/coresemseize.c, score/src/coresemsurrender.c, score/src/corespinlock.c, score/src/threadblockingoperationcancel.c, score/src/threadqenqueue.c: Remove unnecessary include of mpci.h.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  Thread Queue Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-2008.
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_with_handler
31 *
32 *  This routine blocks a thread, places it on a thread, and optionally
33 *  starts a timeout timer.
34 *
35 *  Input parameters:
36 *    the_thread_queue - pointer to threadq
37 *    timeout          - interval to wait
38 *
39 *  Output parameters: NONE
40 *
41 *  INTERRUPT LATENCY:
42 *    only case
43 */
44
45void _Thread_queue_Enqueue_with_handler(
46  Thread_queue_Control         *the_thread_queue,
47  Watchdog_Interval             timeout,
48  Thread_queue_Timeout_callout  handler
49)
50{
51  Thread_Control                   *the_thread;
52  ISR_Level                         level;
53  Thread_blocking_operation_States  sync_state;
54  Thread_blocking_operation_States (*enqueue_p)(
55    Thread_queue_Control *,
56    Thread_Control *,
57    ISR_Level *
58  );
59
60  the_thread = _Thread_Executing;
61
62#if defined(RTEMS_MULTIPROCESSING)
63  if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet )
64    the_thread = _Thread_MP_Allocate_proxy( the_thread_queue->state );
65  else
66#endif
67  /*
68   *  Set the blocking state for this thread queue in the thread.
69   */
70  _Thread_Set_state( the_thread, the_thread_queue->state );
71
72  /*
73   *  If the thread wants to timeout, then schedule its timer.
74   */
75  if ( timeout ) {
76    _Watchdog_Initialize(
77       &the_thread->Timer,
78       handler,
79       the_thread->Object.id,
80       NULL
81    );
82
83    _Watchdog_Insert_ticks( &the_thread->Timer, timeout );
84  }
85
86  /*
87   *  Now enqueue the thread per the discipline for this thread queue.
88   */
89  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY )
90    enqueue_p = _Thread_queue_Enqueue_priority;
91  else /* must be THREAD_QUEUE_DISCIPLINE_FIFO */
92    enqueue_p = _Thread_queue_Enqueue_fifo;
93
94  sync_state = (*enqueue_p)( the_thread_queue, the_thread, &level );
95  if ( sync_state != THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED )
96    _Thread_blocking_operation_Cancel( sync_state, the_thread, level );
97}
Note: See TracBrowser for help on using the repository browser.