source: rtems/cpukit/posix/include/rtems/posix/spinlockimpl.h @ 5a5fb3b

5
Last change on this file since 5a5fb3b was 5a5fb3b, checked in by Sebastian Huber <sebastian.huber@…>, on 03/18/16 at 13:03:01

score: Avoid Giant lock for CORE spinlock

Use an ISR lock to protect the spinlock state. Remove empty attributes.

Update #2555.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines from the POSIX Spinlock Manager
5 *
6 * This file contains the static inlin implementation of the inlined
7 * routines from the POSIX Spinlock Manager.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2011.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_POSIX_SPINLOCKIMPL_H
20#define _RTEMS_POSIX_SPINLOCKIMPL_H
21
22#include <rtems/posix/spinlock.h>
23#include <rtems/score/corespinlockimpl.h>
24#include <rtems/score/objectimpl.h>
25
26#include <pthread.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/**
33 * The following defines the information control block used to manage
34 * this class of objects.
35 */
36
37extern Objects_Information _POSIX_Spinlock_Information;
38
39/**
40 * @brief Translate core spinlock status code.
41 *
42 * This routine translates SuperCore Spinlock status codes into the
43 * corresponding POSIX ones.
44 *
45 * @param[in] the_spinlock_status is the SuperCore status.
46 *
47 * @return the corresponding POSIX status
48 */
49int _POSIX_Spinlock_Translate_core_spinlock_return_code(
50  CORE_spinlock_Status  the_spinlock_status
51);
52
53/**
54 * @brief Allocate a spinlock control block.
55 *
56 * This function allocates a spinlock control block from
57 * the inactive chain of free spinlock control blocks.
58 */
59RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Allocate( void )
60{
61  return (POSIX_Spinlock_Control *)
62    _Objects_Allocate( &_POSIX_Spinlock_Information );
63}
64
65/**
66 * @brief Free a spinlock control block.
67 *
68 * This routine frees a spinlock control block to the
69 * inactive chain of free spinlock control blocks.
70 */
71RTEMS_INLINE_ROUTINE void _POSIX_Spinlock_Free (
72  POSIX_Spinlock_Control *the_spinlock
73)
74{
75  _Objects_Free( &_POSIX_Spinlock_Information, &the_spinlock->Object );
76}
77
78RTEMS_INLINE_ROUTINE POSIX_Spinlock_Control *_POSIX_Spinlock_Get(
79  pthread_spinlock_t *spinlock,
80  ISR_lock_Context   *lock_context
81)
82{
83  if ( spinlock == NULL ) {
84    return NULL;
85  }
86
87  return (POSIX_Spinlock_Control *) _Objects_Get_local(
88    &_POSIX_Spinlock_Information,
89    *spinlock,
90    lock_context
91  );
92}
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif
99/*  end of include file */
Note: See TracBrowser for help on using the repository browser.