source: rtems/cpukit/score/src/threadqenqueue.c @ 6c7caa1a

4.115
Last change on this file since 6c7caa1a was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Thread Queue Enqueue
5 * @ingroup ScoreThreadQ
6 */
7
8/*
9 *  Thread Queue Handler
10 *
11 *
12 *  COPYRIGHT (c) 1989-2008.
13 *  On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.org/license/LICENSE.
18 */
19
20#if HAVE_CONFIG_H
21#include "config.h"
22#endif
23
24#include <rtems/score/threadqimpl.h>
25#include <rtems/score/isrlevel.h>
26#include <rtems/score/threadimpl.h>
27#include <rtems/score/watchdogimpl.h>
28
29void _Thread_queue_Enqueue_with_handler(
30  Thread_queue_Control         *the_thread_queue,
31  Thread_Control               *the_thread,
32  Watchdog_Interval             timeout,
33  Thread_queue_Timeout_callout  handler
34)
35{
36  ISR_Level                         level;
37  Thread_blocking_operation_States  sync_state;
38  Thread_blocking_operation_States (*enqueue_p)(
39    Thread_queue_Control *,
40    Thread_Control *,
41    ISR_Level *
42  );
43
44#if defined(RTEMS_MULTIPROCESSING)
45  if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet )
46    the_thread = _Thread_MP_Allocate_proxy( the_thread_queue->state );
47  else
48#endif
49  /*
50   *  Set the blocking state for this thread queue in the thread.
51   */
52  _Thread_Set_state( the_thread, the_thread_queue->state );
53
54  /*
55   *  If the thread wants to timeout, then schedule its timer.
56   */
57  if ( timeout ) {
58    _Watchdog_Initialize(
59       &the_thread->Timer,
60       handler,
61       the_thread->Object.id,
62       NULL
63    );
64
65    _Watchdog_Insert_ticks( &the_thread->Timer, timeout );
66  }
67
68  /*
69   *  Now enqueue the thread per the discipline for this thread queue.
70   */
71  if ( the_thread_queue->discipline == THREAD_QUEUE_DISCIPLINE_PRIORITY )
72    enqueue_p = _Thread_queue_Enqueue_priority;
73  else /* must be THREAD_QUEUE_DISCIPLINE_FIFO */
74    enqueue_p = _Thread_queue_Enqueue_fifo;
75
76  sync_state = (*enqueue_p)( the_thread_queue, the_thread, &level );
77  if ( sync_state != THREAD_BLOCKING_OPERATION_NOTHING_HAPPENED )
78    _Thread_blocking_operation_Cancel( sync_state, the_thread, level );
79}
Note: See TracBrowser for help on using the repository browser.