source: rtems/cpukit/rtems/src/barriercreate.c @ 4c90eb4

4.115
Last change on this file since 4c90eb4 was 4c90eb4, checked in by Mathew Kallada <matkallada@…>, on 12/08/12 at 13:48:37

misc rtems: Clean up Doxygen GCI Task #8

http://www.google-melange.com/gci/task/view/google/gci2012/8024203

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