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

5
Last change on this file since 04da96c7 was 1e1a91ed, checked in by Sebastian Huber <sebastian.huber@…>, on 03/23/16 at 09:01:31

score: Remove Thread_queue_Queue::operations field

Remove the Thread_queue_Queue::operations field to reduce the size of
this structure. Add a thread queue operations parameter to the
_Thread_queue_First(), _Thread_queue_First_locked(),
_Thread_queue_Enqueue(), _Thread_queue_Dequeue() and
_Thread_queue_Flush() functions. This is a preparation patch to reduce
the size of several synchronization objects.

  • Property mode set to 100644
File size: 1.9 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 <pthread.h>
21#include <errno.h>
22
23#include <rtems/posix/rwlockimpl.h>
24#include <rtems/score/threadqimpl.h>
25
26/**
27 *  This directive allows a thread to delete a rwlock specified by
28 *  the rwlock id.  The rwlock is freed back to the inactive
29 *  rwlock chain.
30 *
31 *  @param[in] rwlock is the rwlock id
32 *
33 *  @return This method returns 0 if there was not an
34 *  error. Otherwise, a status code is returned indicating the
35 *  source of the error.
36 */
37int pthread_rwlock_destroy(
38  pthread_rwlock_t *rwlock
39)
40{
41  POSIX_RWLock_Control *the_rwlock = NULL;
42  Objects_Locations      location;
43
44  _Objects_Allocator_lock();
45  the_rwlock = _POSIX_RWLock_Get( rwlock, &location );
46  switch ( location ) {
47
48    case OBJECTS_LOCAL:
49      /*
50       *  If there is at least one thread waiting, then do not delete it.
51       */
52      if (
53        _Thread_queue_First(
54          &the_rwlock->RWLock.Wait_queue,
55          CORE_RWLOCK_TQ_OPERATIONS
56        ) != NULL
57      ) {
58        _Objects_Put( &the_rwlock->Object );
59        _Objects_Allocator_unlock();
60        return EBUSY;
61      }
62
63      /*
64       *  POSIX doesn't require behavior when it is locked.
65       */
66
67      _Objects_Close( &_POSIX_RWLock_Information, &the_rwlock->Object );
68      _Objects_Put( &the_rwlock->Object );
69      _POSIX_RWLock_Free( the_rwlock );
70      _Objects_Allocator_unlock();
71
72      return 0;
73
74#if defined(RTEMS_MULTIPROCESSING)
75    case OBJECTS_REMOTE:
76#endif
77    case OBJECTS_ERROR:
78      break;
79  }
80
81  _Objects_Allocator_unlock();
82
83  return EINVAL;
84}
Note: See TracBrowser for help on using the repository browser.