source: rtems/cpukit/rtems/src/rtemsobjectsetname.c @ 66cb142

Last change on this file since 66cb142 was f4d541cc, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 27, 2016 at 2:46:57 PM

rtems: Avoid Giant lock in rtems_object_set_name()

Update #2555.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Set Name of Object
5 * @ingroup ClassicClassInfo Object Class Information
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
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#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/object.h>
22#include <rtems/rtems/tasks.h>
23#include <rtems/score/objectimpl.h>
24
25/*
26 *  This method will set the object name based upon the user string.
27 *  If the object class uses 32-bit names, then only the first 4 bytes
28 *  of the string will be used.
29 */
30rtems_status_code rtems_object_set_name(
31  rtems_id       id,
32  const char    *name
33)
34{
35  Objects_Information *information;
36  Objects_Control     *the_object;
37  Objects_Id           tmpId;
38
39  if ( !name )
40    return RTEMS_INVALID_ADDRESS;
41
42  tmpId = (id == OBJECTS_ID_OF_SELF) ? rtems_task_self() : id;
43
44  information  = _Objects_Get_information_id( tmpId );
45  if ( !information )
46    return RTEMS_INVALID_ID;
47
48  _Objects_Allocator_lock();
49  the_object = _Objects_Get_no_protection( tmpId, information );
50
51  if ( the_object == NULL ) {
52    _Objects_Allocator_unlock();
53    return RTEMS_INVALID_ID;
54  }
55
56  _Objects_Set_name( information, the_object, name );
57  _Objects_Allocator_unlock();
58  return RTEMS_SUCCESSFUL;
59}
Note: See TracBrowser for help on using the repository browser.