OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [posix/] [src/] [mutexdestroy.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  mutexdestroy.c,v 1.2 2001/01/24 14:17:28 joel Exp
3
 */
4
 
5
#if HAVE_CONFIG_H
6
#include "config.h"
7
#endif
8
 
9
#include <assert.h>
10
#include <errno.h>
11
#include <pthread.h>
12
 
13
#include <rtems/system.h>
14
#include <rtems/score/coremutex.h>
15
#include <rtems/score/watchdog.h>
16
#if defined(RTEMS_MULTIPROCESSING)
17
#include <rtems/score/mpci.h>
18
#endif
19
#include <rtems/posix/mutex.h>
20
#include <rtems/posix/priority.h>
21
#include <rtems/posix/time.h>
22
 
23
/*PAGE
24
 *
25
 *  11.3.2 Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87
26
 */
27
 
28
int pthread_mutex_destroy(
29
  pthread_mutex_t           *mutex
30
)
31
{
32
  register POSIX_Mutex_Control *the_mutex;
33
  Objects_Locations             location;
34
 
35
  the_mutex = _POSIX_Mutex_Get( mutex, &location );
36
  switch ( location ) {
37
    case OBJECTS_REMOTE:
38
#if defined(RTEMS_MULTIPROCESSING)
39
      _Thread_Dispatch();
40
      return POSIX_MP_NOT_IMPLEMENTED();
41
      return EINVAL;
42
#endif
43
    case OBJECTS_ERROR:
44
      return EINVAL;
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 ) ) {
52
        _Thread_Enable_dispatch();
53
        return EBUSY;
54
      }
55
 
56
      _Objects_Close( &_POSIX_Mutex_Information, &the_mutex->Object );
57
 
58
      _CORE_mutex_Flush(
59
        &the_mutex->Mutex,
60
#if defined(RTEMS_MULTIPROCESSING)
61
        _POSIX_Mutex_MP_Send_object_was_deleted,
62
#else
63
        NULL,
64
#endif
65
        EINVAL
66
      );
67
 
68
      _POSIX_Mutex_Free( the_mutex );
69
 
70
#if defined(RTEMS_MULTIPROCESSING)
71
      if ( the_mutex->process_shared == PTHREAD_PROCESS_SHARED ) {
72
 
73
        _Objects_MP_Close( &_POSIX_Mutex_Information, the_mutex->Object.id );
74
 
75
        _POSIX_Mutex_MP_Send_process_packet(
76
          POSIX_MUTEX_MP_ANNOUNCE_DELETE,
77
          the_mutex->Object.id,
78
          0,                         /* Not used */
79
 
80
        );
81
      }
82
#endif
83
      _Thread_Enable_dispatch();
84
      return 0;
85
  }
86
  return POSIX_BOTTOM_REACHED();
87
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.