source: rtems/cpukit/posix/src/conddestroy.c @ 23fec9f0

4.115
Last change on this file since 23fec9f0 was 23fec9f0, checked in by Sebastian Huber <sebastian.huber@…>, on 03/27/14 at 13:16:12

score: PR2152: Use allocator mutex for objects

Use allocator mutex for objects allocate/free. This prevents that the
thread dispatch latency depends on the workspace/heap fragmentation.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Destroy a Condition Variable
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 <pthread.h>
22#include <errno.h>
23
24#include <rtems/system.h>
25#include <rtems/score/watchdog.h>
26#include <rtems/posix/condimpl.h>
27#include <rtems/posix/time.h>
28#include <rtems/posix/muteximpl.h>
29
30/**
31 *  11.4.2 Initializing and Destroying a Condition Variable,
32 *         P1003.1c/Draft 10, p. 87
33 */
34int pthread_cond_destroy(
35  pthread_cond_t           *cond
36)
37{
38  POSIX_Condition_variables_Control *the_cond;
39  Objects_Locations                  location;
40
41  _Objects_Allocator_lock();
42  the_cond = _POSIX_Condition_variables_Get( cond, &location );
43  switch ( location ) {
44
45    case OBJECTS_LOCAL:
46
47      if ( _Thread_queue_First( &the_cond->Wait_queue ) ) {
48        _Objects_Put( &the_cond->Object );
49        _Objects_Allocator_unlock();
50        return EBUSY;
51      }
52
53      _Objects_Close(
54        &_POSIX_Condition_variables_Information,
55        &the_cond->Object
56      );
57      _Objects_Put( &the_cond->Object );
58      _POSIX_Condition_variables_Free( the_cond );
59      _Objects_Allocator_unlock();
60      return 0;
61
62#if defined(RTEMS_MULTIPROCESSING)
63    case OBJECTS_REMOTE:
64#endif
65    case OBJECTS_ERROR:
66      break;
67  }
68
69  _Objects_Allocator_unlock();
70
71  return EINVAL;
72}
Note: See TracBrowser for help on using the repository browser.