source: rtems/cpukit/rtems/src/barriercreate.c @ 8042961d

4.104.114.84.95
Last change on this file since 8042961d was 8042961d, checked in by Joel Sherrill <joel.sherrill@…>, on 09/25/06 at 13:38:24

2006-09-25 Joel Sherrill <joel.sherrill@…>

  • rtems/Makefile.am, rtems/preinstall.am, rtems/include/rtems.h, rtems/include/rtems/rtems/attr.h, rtems/include/rtems/rtems/config.h, rtems/inline/rtems/rtems/attr.inl, rtems/macros/rtems/rtems/attr.inl: Add Classic API Barriers.
  • rtems/include/rtems/rtems/barrier.h, rtems/include/rtems/rtems/barriermp.h, rtems/inline/rtems/rtems/barrier.inl, rtems/macros/rtems/rtems/barrier.inl, rtems/src/barrier.c, rtems/src/barriercreate.c, rtems/src/barrierdelete.c, rtems/src/barrierident.c, rtems/src/barrierrelease.c, rtems/src/barriertranslatereturncode.c, rtems/src/barrierwait.c: New files.
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  Barrier Manager -- Create a Barrier Instance
3 *
4 *  COPYRIGHT (c) 1989-2006.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/rtems/status.h>
20#include <rtems/rtems/support.h>
21#include <rtems/rtems/attr.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/rtems/barrier.h>
25
26/*
27 *  rtems_barrier_create
28 *
29 *  This directive creates a barrier.  A barrier id is returned.
30 *
31 *  Input parameters:
32 *    name             - user defined barrier name
33 *    attribute_set    - barrier attributes
34 *    maximum_waiters  - number of threads before automatic release
35 *    priority_ceiling - barrier's ceiling priority
36 *    id               - pointer to barrier id
37 *
38 *  Output parameters:
39 *    id               - barrier id
40 *    RTEMS_SUCCESSFUL - if successful
41 *    error code       - if unsuccessful
42 */
43
44rtems_status_code rtems_barrier_create(
45  rtems_name           name,
46  rtems_attribute      attribute_set,
47  uint32_t             maximum_waiters,
48  rtems_id            *id
49)
50{
51  Barrier_Control         *the_barrier;
52  CORE_barrier_Attributes  the_attributes;
53
54  if ( !rtems_is_name_valid( name ) )
55    return RTEMS_INVALID_NAME;
56
57  if ( !id )
58    return RTEMS_INVALID_ADDRESS;
59
60  /* Initialize core barrier attributes */
61  if ( _Attributes_Is_barrier_automatic( attribute_set ) ) {
62    the_attributes.discipline = CORE_BARRIER_AUTOMATIC_RELEASE;
63    if ( maximum_waiters == 0 )
64      return RTEMS_INVALID_NUMBER;
65  } else
66    the_attributes.discipline = CORE_BARRIER_MANUAL_RELEASE;
67  the_attributes.maximum_count = maximum_waiters;
68
69  _Thread_Disable_dispatch();             /* prevents deletion */
70
71  the_barrier = _Barrier_Allocate();
72
73  if ( !the_barrier ) {
74    _Thread_Enable_dispatch();
75    return RTEMS_TOO_MANY;
76  }
77
78  the_barrier->attribute_set = attribute_set;
79
80  _CORE_barrier_Initialize( &the_barrier->Barrier, &the_attributes );
81
82  _Objects_Open(
83    &_Barrier_Information,
84    &the_barrier->Object,
85    (Objects_Name) name
86  );
87
88  *id = the_barrier->Object.id;
89
90  _Thread_Enable_dispatch();
91  return RTEMS_SUCCESSFUL;
92}
Note: See TracBrowser for help on using the repository browser.