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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [mutexdestroy.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  $Id: mutexdestroy.c,v 1.2 2001-09-27 11:59:17 chris Exp $
3
 */
4
 
5
#include <assert.h>
6
#include <errno.h>
7
#include <pthread.h>
8
 
9
#include <rtems/system.h>
10
#include <rtems/score/coremutex.h>
11
#include <rtems/score/watchdog.h>
12
#if defined(RTEMS_MULTIPROCESSING)
13
#include <rtems/score/mpci.h>
14
#endif
15
#include <rtems/posix/mutex.h>
16
#include <rtems/posix/priority.h>
17
#include <rtems/posix/time.h>
18
 
19
/*PAGE
20
 *
21
 *  11.3.2 Initializing and Destroying a Mutex, P1003.1c/Draft 10, p. 87
22
 */
23
 
24
int pthread_mutex_destroy(
25
  pthread_mutex_t           *mutex
26
)
27
{
28
  register POSIX_Mutex_Control *the_mutex;
29
  Objects_Locations             location;
30
 
31
  the_mutex = _POSIX_Mutex_Get( mutex, &location );
32
  switch ( location ) {
33
    case OBJECTS_REMOTE:
34
#if defined(RTEMS_MULTIPROCESSING)
35
      _Thread_Dispatch();
36
      return POSIX_MP_NOT_IMPLEMENTED();
37
      return EINVAL;
38
#endif
39
    case OBJECTS_ERROR:
40
      return EINVAL;
41
    case OBJECTS_LOCAL:
42
       /*
43
        * XXX: There is an error for the mutex being locked
44
        *  or being in use by a condition variable.
45
        */
46
 
47
      if ( _CORE_mutex_Is_locked( &the_mutex->Mutex ) ) {
48
        _Thread_Enable_dispatch();
49
        return EBUSY;
50
      }
51
 
52
      _Objects_Close( &_POSIX_Mutex_Information, &the_mutex->Object );
53
 
54
      _CORE_mutex_Flush(
55
        &the_mutex->Mutex,
56
#if defined(RTEMS_MULTIPROCESSING)
57
        _POSIX_Mutex_MP_Send_object_was_deleted,
58
#else
59
        NULL,
60
#endif
61
        EINVAL
62
      );
63
 
64
      _POSIX_Mutex_Free( the_mutex );
65
 
66
#if defined(RTEMS_MULTIPROCESSING)
67
      if ( the_mutex->process_shared == PTHREAD_PROCESS_SHARED ) {
68
 
69
        _Objects_MP_Close( &_POSIX_Mutex_Information, the_mutex->Object.id );
70
 
71
        _POSIX_Mutex_MP_Send_process_packet(
72
          POSIX_MUTEX_MP_ANNOUNCE_DELETE,
73
          the_mutex->Object.id,
74
          0,                         /* Not used */
75
 
76
        );
77
      }
78
#endif
79
      _Thread_Enable_dispatch();
80
      return 0;
81
  }
82
  return POSIX_BOTTOM_REACHED();
83
}

powered by: WebSVN 2.1.0

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