source: rtems/cpukit/posix/src/mutexdestroy.c @ 9809d6e0

5
Last change on this file since 9809d6e0 was 9809d6e0, checked in by Sebastian Huber <sebastian.huber@…>, on 03/30/16 at 09:39:58

score: _Thread_queue_Flush() parameter changes

Change _Thread_queue_Flush() into a macro that invokes
_Thread_queue_Do_flush() with the parameter set defined by
RTEMS_MULTIPROCESSING. For multiprocessing configurations add the
object identifier to avoid direct use of the thread wait information.

Use mp_ prefix for multiprocessing related parameters.

Rename Thread_queue_Flush_callout to Thread_queue_MP_callout since this
type will be re-used later for other operations as well.

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[810ecf0]1/**
2 * @file
3 *
4 * @brief Initializing and Destroying a Mutex
[5cb175bb]5 * @ingroup POSIXAPI
[810ecf0]6 */
7
[96c041c]8/*
[feaa007]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
[c499856]14 *  http://www.rtems.org/license/LICENSE.
[96c041c]15 */
16
[f42b726]17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
[96c041c]21#include <errno.h>
22#include <pthread.h>
23
24#include <rtems/system.h>
[20e239c2]25#include <rtems/score/coremuteximpl.h>
[96c041c]26#include <rtems/score/watchdog.h>
[f9d533a5]27#include <rtems/posix/muteximpl.h>
[97552c98]28#include <rtems/posix/priorityimpl.h>
[96c041c]29
[64adc13]30/*
[96c041c]31 *  11.3.2 Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87
32 */
33
34int pthread_mutex_destroy(
35  pthread_mutex_t           *mutex
36)
37{
38  register POSIX_Mutex_Control *the_mutex;
39  Objects_Locations             location;
[874297f3]40
[23fec9f0]41  _Objects_Allocator_lock();
[96c041c]42  the_mutex = _POSIX_Mutex_Get( mutex, &location );
43  switch ( location ) {
[860c34e]44
[96c041c]45    case OBJECTS_LOCAL:
46       /*
47        * XXX: There is an error for the mutex being locked
48        *  or being in use by a condition variable.
49        */
50
51      if ( _CORE_mutex_Is_locked( &the_mutex->Mutex ) ) {
[2d2352b]52        _Objects_Put( &the_mutex->Object );
[23fec9f0]53        _Objects_Allocator_unlock();
[96c041c]54        return EBUSY;
55      }
[874297f3]56
[96c041c]57      _Objects_Close( &_POSIX_Mutex_Information, &the_mutex->Object );
[9809d6e0]58      _CORE_mutex_Flush( &the_mutex->Mutex, EINVAL, NULL, 0 );
[2d2352b]59      _Objects_Put( &the_mutex->Object );
[23fec9f0]60      _POSIX_Mutex_Free( the_mutex );
61      _Objects_Allocator_unlock();
62
[96c041c]63      return 0;
[860c34e]64
65#if defined(RTEMS_MULTIPROCESSING)
66    case OBJECTS_REMOTE:
67#endif
68    case OBJECTS_ERROR:
69      break;
[96c041c]70  }
[860c34e]71
[23fec9f0]72  _Objects_Allocator_unlock();
73
[860c34e]74  return EINVAL;
[96c041c]75}
Note: See TracBrowser for help on using the repository browser.