source: rtems/cpukit/score/src/threadqenqueue.c @ 471998ec

4.104.114.84.95
Last change on this file since 471998ec was 047d67a, checked in by Joel Sherrill <joel.sherrill@…>, on 11/15/06 at 14:08:49

2006-11-15 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/termios.c, posix/Makefile.am, posix/preinstall.am, posix/include/rtems/posix/config.h, posix/include/rtems/posix/time.h, sapi/src/posixapi.c, score/Makefile.am, score/preinstall.am, score/include/rtems/score/corerwlock.h, score/include/rtems/score/threadq.h, score/src/corerwlockobtainread.c, score/src/threadqenqueue.c, score/src/threadqtimeout.c: Adding POSIX barriers, POSIX spinlocks, and partial implementation of POSIX rwlocks.
  • posix/include/rtems/posix/barrier.h, posix/include/rtems/posix/rwlock.h, posix/include/rtems/posix/spinlock.h, posix/inline/rtems/posix/barrier.inl, posix/inline/rtems/posix/rwlock.inl, posix/inline/rtems/posix/spinlock.inl, posix/src/barrierattrdestroy.c, posix/src/barrierattrgetpshared.c, posix/src/barrierattrinit.c, posix/src/barrierattrsetpshared.c, posix/src/pbarrier.c, posix/src/pbarrierdestroy.c, posix/src/pbarrierinit.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlock.c, posix/src/prwlockdestroy.c, posix/src/prwlockinit.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspin.c, posix/src/pspindestroy.c, posix/src/pspininit.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/rwlockattrdestroy.c, posix/src/rwlockattrgetpshared.c, posix/src/rwlockattrinit.c, posix/src/rwlockattrsetpshared.c: New files.
  • Property mode set to 100644
File size: 2.0 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#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    _Thread_Set_state( the_thread, the_thread_queue->state );
64
65  if ( timeout ) {
66    _Watchdog_Initialize(
67       &the_thread->Timer,
68       handler,
69       the_thread->Object.id,
70       NULL
71    );
72
73    _Watchdog_Insert_ticks( &the_thread->Timer, timeout );
74  }
75
76  switch( the_thread_queue->discipline ) {
77    case THREAD_QUEUE_DISCIPLINE_FIFO:
78      _Thread_queue_Enqueue_fifo( the_thread_queue, the_thread );
79      break;
80    case THREAD_QUEUE_DISCIPLINE_PRIORITY:
81      _Thread_queue_Enqueue_priority( the_thread_queue, the_thread );
82      break;
83  }
84}
Note: See TracBrowser for help on using the repository browser.