source: rtems/cpukit/rtems/src/barriercreate.c @ 21275b58

Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2018 at 6:14:51 PM

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 1.9 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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/barrierimpl.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/rtems/attrimpl.h>
25#include <rtems/score/isr.h>
26#include <rtems/sysinit.h>
27
28rtems_status_code rtems_barrier_create(
29  rtems_name           name,
30  rtems_attribute      attribute_set,
31  uint32_t             maximum_waiters,
32  rtems_id            *id
33)
34{
35  Barrier_Control         *the_barrier;
36  CORE_barrier_Attributes  the_attributes;
37
38  if ( !rtems_is_name_valid( name ) )
39    return RTEMS_INVALID_NAME;
40
41  if ( !id )
42    return RTEMS_INVALID_ADDRESS;
43
44  /* Initialize core barrier attributes */
45  if ( _Attributes_Is_barrier_automatic( attribute_set ) ) {
46    the_attributes.discipline = CORE_BARRIER_AUTOMATIC_RELEASE;
47    if ( maximum_waiters == 0 )
48      return RTEMS_INVALID_NUMBER;
49  } else
50    the_attributes.discipline = CORE_BARRIER_MANUAL_RELEASE;
51  the_attributes.maximum_count = maximum_waiters;
52
53  the_barrier = _Barrier_Allocate();
54
55  if ( !the_barrier ) {
56    _Objects_Allocator_unlock();
57    return RTEMS_TOO_MANY;
58  }
59
60  the_barrier->attribute_set = attribute_set;
61
62  _CORE_barrier_Initialize( &the_barrier->Barrier, &the_attributes );
63
64  _Objects_Open(
65    &_Barrier_Information,
66    &the_barrier->Object,
67    (Objects_Name) name
68  );
69
70  *id = the_barrier->Object.id;
71
72  _Objects_Allocator_unlock();
73  return RTEMS_SUCCESSFUL;
74}
75
76static void _Barrier_Manager_initialization( void )
77{
78  _Objects_Initialize_information( &_Barrier_Information );
79}
80
81RTEMS_SYSINIT_ITEM(
82  _Barrier_Manager_initialization,
83  RTEMS_SYSINIT_CLASSIC_BARRIER,
84  RTEMS_SYSINIT_ORDER_MIDDLE
85);
Note: See TracBrowser for help on using the repository browser.