source: rtems/cpukit/sapi/src/extensioncreate.c @ 599d71f

5
Last change on this file since 599d71f was 23fec9f0, checked in by Sebastian Huber <sebastian.huber@…>, on 03/27/14 at 13:16:12

score: PR2152: Use allocator mutex for objects

Use allocator mutex for objects allocate/free. This prevents that the
thread dispatch latency depends on the workspace/heap fragmentation.

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[c42d1a4]1/**
2 * @file
3 *
4 * @ingroup ClassicUserExtensions
[ac97074f]5 *
[c42d1a4]6 * @brief User Extensions Implementation.
7 */
[28352fae]8
[c42d1a4]9/*
[30cd5393]10 *  COPYRIGHT (c) 1989-2007.
[ac97074f]11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
[c499856]15 *  http://www.rtems.org/license/LICENSE.
[ac97074f]16 */
17
[16351f7a]18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
[ac97074f]22#include <rtems/system.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/thread.h>
[3be0c9a]25#include <rtems/score/userextimpl.h>
[ac252bdc]26#include <rtems/extensionimpl.h>
[ac97074f]27
28rtems_status_code rtems_extension_create(
[b7de5de]29  rtems_name                    name,
30  const rtems_extensions_table *extension_table,
31  rtems_id                     *id
[ac97074f]32)
33{
34  Extension_Control *the_extension;
35
[30cd5393]36  if ( !id )
37    return RTEMS_INVALID_ADDRESS;
38
[ac97074f]39  if ( !rtems_is_name_valid( name ) )
40    return RTEMS_INVALID_NAME;
41
42  the_extension = _Extension_Allocate();
43
44  if ( !the_extension ) {
[23fec9f0]45    _Objects_Allocator_unlock();
[ac97074f]46    return RTEMS_TOO_MANY;
47  }
48
[23fec9f0]49  _Thread_Disable_dispatch();
[c42d1a4]50  _User_extensions_Add_set_with_table( &the_extension->Extension, extension_table );
[23fec9f0]51  _Thread_Enable_dispatch();
[ac97074f]52
[e36865d]53  _Objects_Open(
54    &_Extension_Information,
55    &the_extension->Object,
56    (Objects_Name) name
57  );
[ac97074f]58
59  *id = the_extension->Object.id;
[23fec9f0]60  _Objects_Allocator_unlock();
[ac97074f]61  return RTEMS_SUCCESSFUL;
62}
Note: See TracBrowser for help on using the repository browser.