source: rtems/cpukit/rtems/src/rtemsobjectgetapiclassname.c @ c42be504

5
Last change on this file since c42be504 was c42be504, checked in by Sebastian Huber <sebastian.huber@…>, on 11/16/16 at 13:50:09

posix: Add self-contained pthread spinlock

Turn pthread_spinlock_t into a self-contained object. On uni-processor
configurations, interrupts are disabled in the lock/trylock operations
and the previous interrupt status is restored in the corresponding
unlock operations. On SMP configurations, a ticket lock is a acquired
and released in addition.

The self-contained pthread_spinlock_t object is defined by Newlib in
<sys/_pthreadtypes.h>.

typedef struct {

struct _Ticket_lock_Control _lock;
uint32_t _interrupt_state;

} pthread_spinlock_t;

This implementation is simple and efficient. However, this test case of
the Linux Test Project would fail due to call of printf() and sleep()
during spin lock ownership:

https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_lock/1-2.c

There is only limited support for profiling on SMP configurations.

Delete CORE spinlock implementation.

Update #2674.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Get Class Name
5 *  @ingroup ClassicClassInfo
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/score/objectimpl.h>
23
24#include <rtems/assoc.h>
25
26static const rtems_assoc_t rtems_object_api_internal_assoc[] = {
27  { "Thread",                  OBJECTS_INTERNAL_THREADS, 0},
28  { "Mutex",                   OBJECTS_INTERNAL_MUTEXES, 0},
29  { NULL,                      0, 0}
30};
31
32static const rtems_assoc_t rtems_object_api_classic_assoc[] = {
33  { "Task",                    OBJECTS_RTEMS_TASKS, 0},
34  { "Timer",                   OBJECTS_RTEMS_TIMERS, 0},
35  { "Semaphore",               OBJECTS_RTEMS_SEMAPHORES, 0},
36  { "Message Queue",           OBJECTS_RTEMS_MESSAGE_QUEUES, 0},
37  { "Partition",               OBJECTS_RTEMS_PARTITIONS, 0},
38  { "Region",                  OBJECTS_RTEMS_REGIONS, 0},
39  { "Port",                    OBJECTS_RTEMS_PORTS, 0},
40  { "Period",                  OBJECTS_RTEMS_PERIODS, 0},
41  { "Extension",               OBJECTS_RTEMS_EXTENSIONS, 0},
42  { "Barrier",                 OBJECTS_RTEMS_BARRIERS, 0},
43  { NULL,                      0, 0}
44};
45
46#ifdef RTEMS_POSIX_API
47static const rtems_assoc_t rtems_object_api_posix_assoc[] = {
48  { "Thread",                  OBJECTS_POSIX_THREADS, 0},
49  { "Key",                     OBJECTS_POSIX_KEYS, 0},
50  { "Interrupt",               OBJECTS_POSIX_INTERRUPTS, 0},
51  { "Message Queue",           OBJECTS_POSIX_MESSAGE_QUEUES, 0},
52  { "Mutex",                   OBJECTS_POSIX_MUTEXES, 0},
53  { "Semaphore",               OBJECTS_POSIX_SEMAPHORES, 0},
54  { "Condition Variable",      OBJECTS_POSIX_CONDITION_VARIABLES, 0},
55  { "Timer",                   OBJECTS_POSIX_TIMERS, 0},
56  { "Barrier",                 OBJECTS_POSIX_BARRIERS, 0},
57  { "RWLock",                  OBJECTS_POSIX_RWLOCKS, 0},
58  { NULL,                      0, 0}
59};
60#endif
61
62const char *rtems_object_get_api_class_name(
63  int the_api,
64  int the_class
65)
66{
67  const rtems_assoc_t *api_assoc;
68  const rtems_assoc_t *class_assoc;
69
70  if ( the_api == OBJECTS_INTERNAL_API )
71    api_assoc = rtems_object_api_internal_assoc;
72  else if ( the_api == OBJECTS_CLASSIC_API )
73    api_assoc = rtems_object_api_classic_assoc;
74#ifdef RTEMS_POSIX_API
75  else if ( the_api == OBJECTS_POSIX_API )
76    api_assoc = rtems_object_api_posix_assoc;
77#endif
78  else
79    return "BAD API";
80  class_assoc = rtems_assoc_ptr_by_local( api_assoc, the_class );
81  if ( class_assoc )
82    return class_assoc->name;
83  return "BAD CLASS";
84}
Note: See TracBrowser for help on using the repository browser.