source: rtems/cpukit/posix/src/mutexdestroy.c @ 976162a6

4.104.114.9
Last change on this file since 976162a6 was 976162a6, checked in by Joel Sherrill <joel.sherrill@…>, on Dec 3, 2007 at 10:23:13 PM

2007-12-03 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/malloc.c, libmisc/monitor/mon-command.c, posix/preinstall.am, posix/include/rtems/posix/cond.h, posix/include/rtems/posix/mqueue.h, posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/pthread.h, posix/include/rtems/posix/semaphore.h, posix/src/conddestroy.c, posix/src/mutexdestroy.c, posix/src/mutexinit.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, sapi/include/confdefs.h, sapi/include/rtems/config.h, sapi/include/rtems/init.h, sapi/include/rtems/sptables.h, sapi/src/exinit.c, score/include/rtems/system.h, score/include/rtems/score/mpci.h, score/src/mpci.c, score/src/thread.c, score/src/threadcreateidle.c, score/src/threadstackallocate.c, score/src/threadstackfree.c, score/src/wkspace.c: Moved most of the remaining CPU Table fields to the Configuration Table. This included pretasking_hook, predriver_hook, postdriver_hook, idle_task, do_zero_of_workspace, extra_mpci_receive_server_stack, stack_allocate_hook, and stack_free_hook. As a side-effect of this effort some multiprocessing code was made conditional and some style clean up occurred.
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 *  $Id$
3 */
4
5#if HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include <errno.h>
10#include <pthread.h>
11
12#include <rtems/system.h>
13#include <rtems/score/coremutex.h>
14#include <rtems/score/watchdog.h>
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
24int 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
34    case OBJECTS_LOCAL:
35       /*
36        * XXX: There is an error for the mutex being locked
37        *  or being in use by a condition variable.
38        */
39
40      if ( _CORE_mutex_Is_locked( &the_mutex->Mutex ) ) {
41        _Thread_Enable_dispatch();
42        return EBUSY;
43      }
44
45      _Objects_Close( &_POSIX_Mutex_Information, &the_mutex->Object );
46
47      _CORE_mutex_Flush( &the_mutex->Mutex, NULL, EINVAL );
48
49      _POSIX_Mutex_Free( the_mutex );
50      _Thread_Enable_dispatch();
51      return 0;
52
53#if defined(RTEMS_MULTIPROCESSING)
54    case OBJECTS_REMOTE:
55#endif
56    case OBJECTS_ERROR:
57      break;
58  }
59
60  return EINVAL;
61}
Note: See TracBrowser for help on using the repository browser.