source: rtems/cpukit/score/src/corebarrierwait.c @ b72e847b

4.8
Last change on this file since b72e847b was 9c191ee, checked in by Joel Sherrill <joel.sherrill@…>, on 09/25/06 at 13:36:58
  • score/Makefile.am, score/preinstall.am, score/include/rtems/score/coresem.h, score/include/rtems/score/object.h, score/include/rtems/score/states.h, score/inline/rtems/score/coresem.inl: Add SuperCore? Barriers, SpinLocks? and a partial implementation of RWLocks.
  • score/include/rtems/score/corebarrier.h, score/include/rtems/score/corerwlock.h, score/include/rtems/score/corespinlock.h, score/inline/rtems/score/corebarrier.inl, score/inline/rtems/score/corerwlock.inl, score/inline/rtems/score/corespinlock.inl, score/macros/rtems/score/corebarrier.inl, score/macros/rtems/score/corerwlock.inl, score/macros/rtems/score/corespinlock.inl, score/src/corebarrier.c, score/src/corebarrierrelease.c, score/src/corebarrierwait.c, score/src/corerwlock.c, score/src/corerwlockobtainread.c, score/src/corerwlockobtainwrite.c, score/src/corerwlockrelease.c, score/src/corespinlock.c, score/src/corespinlockrelease.c, score/src/corespinlockwait.c: New files.
  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  SuperCore Barrier Handler
3 *
4 *  DESCRIPTION:
5 *
6 *  This package is part of the implementation of the SuperCore Barrier Handler.
7 *
8 *  COPYRIGHT (c) 1989-2006.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/system.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/corebarrier.h>
25#include <rtems/score/states.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/threadq.h>
28#if defined(RTEMS_MULTIPROCESSING)
29#include <rtems/score/mpci.h>
30#endif
31
32/*PAGE
33 *
34 *  _CORE_barrier_Wait
35 *
36 *  Input parameters:
37 *    the_barrier - pointer to barrier control block
38 *    id          - id of object to wait on
39 *    wait        - TRUE if wait is allowed, FALSE otherwise
40 *    timeout     - number of ticks to wait (0 means forever)
41 *    api_barrier_mp_support - api dependent MP support actions
42 *
43 *  Output parameters:  NONE
44 *
45 *  INTERRUPT LATENCY:
46 *    available
47 *    wait
48 */
49
50void _CORE_barrier_Wait(
51  CORE_barrier_Control                *the_barrier,
52  Objects_Id                           id,
53  boolean                              wait,
54  Watchdog_Interval                    timeout,
55  CORE_barrier_API_mp_support_callout  api_barrier_mp_support
56)
57{
58  Thread_Control *executing;
59  ISR_Level       level;
60
61  executing = _Thread_Executing;
62  executing->Wait.return_code = CORE_BARRIER_STATUS_SUCCESSFUL;
63  _ISR_Disable( level );
64  the_barrier->number_of_waiting_threads++;
65  if ( the_barrier->number_of_waiting_threads ==
66       the_barrier->Attributes.maximum_count) {
67    if ( _CORE_barrier_Is_automatic( &the_barrier->Attributes ) ) {
68      executing->Wait.return_code = CORE_BARRIER_STATUS_AUTOMATICALLY_RELEASED;
69      _ISR_Enable( level );
70      _CORE_barrier_Release( the_barrier, id, api_barrier_mp_support );
71      return;
72    }
73  }
74
75  _Thread_queue_Enter_critical_section( &the_barrier->Wait_queue );
76  executing->Wait.queue          = &the_barrier->Wait_queue;
77  executing->Wait.id             = id;
78  _ISR_Enable( level );
79
80  _Thread_queue_Enqueue( &the_barrier->Wait_queue, timeout );
81}
Note: See TracBrowser for help on using the repository browser.