source: rtems/cpukit/posix/src/mutexunlock.c @ 33e250c9

5
Last change on this file since 33e250c9 was 33e250c9, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/16 at 13:41:41

score: Rework CORE priority ceiling mutex

Rework seize and surrender methods to use CORE_ceiling_mutex_Control.
This eliminates CORE_mutex_Disciplines.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief Locking and Unlocking a Mutex
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 <rtems/posix/muteximpl.h>
22#include <rtems/posix/posixapi.h>
23
24/*
25 *  11.3.3 Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93
26 *
27 *  NOTE: P1003.4b/D8 adds pthread_mutex_timedlock(), p. 29
28 */
29
30int pthread_mutex_unlock(
31  pthread_mutex_t           *mutex
32)
33{
34  POSIX_Mutex_Control  *the_mutex;
35  Thread_queue_Context  queue_context;
36  Thread_Control       *executing;
37  Status_Control        status;
38
39  the_mutex = _POSIX_Mutex_Get( mutex, &queue_context );
40
41  if ( the_mutex == NULL ) {
42    return EINVAL;
43  }
44
45  executing = _Thread_Executing;
46
47  switch ( the_mutex->protocol ) {
48    case POSIX_MUTEX_PRIORITY_CEILING:
49      status = _CORE_ceiling_mutex_Surrender(
50        &the_mutex->Mutex,
51        executing,
52        &queue_context
53      );
54      break;
55    case POSIX_MUTEX_NO_PROTOCOL:
56      status = _CORE_recursive_mutex_Surrender_no_protocol(
57        &the_mutex->Mutex.Recursive,
58        POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
59        executing,
60        &queue_context
61      );
62      break;
63    default:
64      _Assert( the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT );
65      status = _CORE_mutex_Surrender(
66        &the_mutex->Mutex.Recursive.Mutex,
67        &queue_context
68      );
69      break;
70  }
71
72  return _POSIX_Get_error( status );
73}
Note: See TracBrowser for help on using the repository browser.