source: rtems/cpukit/posix/src/pspindestroy.c @ 04da96c7

5
Last change on this file since 04da96c7 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: 1.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Destroy a Spinlock
5 *  @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
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/posix/spinlockimpl.h>
22
23#include <errno.h>
24
25int pthread_spin_destroy( pthread_spinlock_t *spinlock )
26{
27  POSIX_Spinlock_Control *the_spinlock;
28  ISR_lock_Context        lock_context;
29
30  _Objects_Allocator_lock();
31
32  the_spinlock = _POSIX_Spinlock_Get( spinlock, &lock_context );
33  if ( the_spinlock == NULL ) {
34    _Objects_Allocator_unlock();
35    return EINVAL;
36  }
37
38  _CORE_spinlock_Acquire_critical( &the_spinlock->Spinlock, &lock_context );
39
40  if ( _CORE_spinlock_Is_busy( &the_spinlock->Spinlock ) ) {
41    _CORE_spinlock_Release( &the_spinlock->Spinlock, &lock_context );
42    _Objects_Allocator_unlock();
43    return EBUSY;
44  }
45
46  _CORE_spinlock_Release( &the_spinlock->Spinlock, &lock_context );
47
48  _Objects_Close( &_POSIX_Spinlock_Information, &the_spinlock->Object );
49  _POSIX_Spinlock_Free( the_spinlock );
50  _Objects_Allocator_unlock();
51  return 0;
52}
Note: See TracBrowser for help on using the repository browser.