source: rtems/cpukit/posix/src/prwlockdestroy.c @ 127c20eb

5
Last change on this file since 127c20eb was 631b3c8, checked in by Sebastian Huber <sebastian.huber@…>, on 05/23/16 at 09:40:18

score: Move thread queue MP callout to context

Drop the multiprocessing (MP) dependent callout parameter from the
thread queue extract, dequeue, flush and unblock methods. Merge this
parameter with the lock context into new structure Thread_queue_Context.
This helps to gets rid of the conditionally compiled method call
helpers.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Destroy a RWLock
5 *  @ingroup POSIXAPI
6 */
7/*
8 *  COPYRIGHT (c) 1989-2007.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#if HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <rtems/posix/rwlockimpl.h>
21
22int pthread_rwlock_destroy(
23  pthread_rwlock_t *rwlock
24)
25{
26  POSIX_RWLock_Control *the_rwlock;
27  Thread_queue_Context  queue_context;
28
29  _Objects_Allocator_lock();
30  the_rwlock = _POSIX_RWLock_Get( rwlock, &queue_context );
31
32  if ( the_rwlock == NULL ) {
33    _Objects_Allocator_unlock();
34    return EINVAL;
35  }
36
37  _CORE_RWLock_Acquire_critical( &the_rwlock->RWLock, &queue_context );
38
39  /*
40   *  If there is at least one thread waiting, then do not delete it.
41   */
42
43  if ( !_Thread_queue_Is_empty( &the_rwlock->RWLock.Wait_queue.Queue ) ) {
44    _CORE_RWLock_Release( &the_rwlock->RWLock, &queue_context );
45    _Objects_Allocator_unlock();
46    return EBUSY;
47  }
48
49  /*
50   *  POSIX doesn't require behavior when it is locked.
51   */
52
53  _Objects_Close( &_POSIX_RWLock_Information, &the_rwlock->Object );
54  _CORE_RWLock_Release( &the_rwlock->RWLock, &queue_context );
55  _POSIX_RWLock_Free( the_rwlock );
56  _Objects_Allocator_unlock();
57  return 0;
58}
Note: See TracBrowser for help on using the repository browser.