source: rtems/cpukit/score/src/apimutex.c @ 25f5730f

4.11
Last change on this file since 25f5730f was 03e89287, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 27, 2014 at 1:46:31 PM

score: Delete CORE_mutex_Control::lock

The holder field is enough to determine if a mutex is locked or not.

This leads also to better error status codes in case a
rtems_semaphore_release() is done for a mutex without having the
ownership.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Initialization and Allocation for API Mutex Handler
5 *
6 * @ingroup ScoreAPIMutex
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2007.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/score/apimutex.h>
23#include <rtems/score/coremuteximpl.h>
24#include <rtems/score/objectimpl.h>
25
26static Objects_Information _API_Mutex_Information;
27
28void _API_Mutex_Initialization(
29  uint32_t maximum_mutexes
30)
31{
32  _Objects_Initialize_information(
33    &_API_Mutex_Information,     /* object information table */
34    OBJECTS_INTERNAL_API,        /* object API */
35    OBJECTS_INTERNAL_MUTEXES,    /* object class */
36    maximum_mutexes,             /* maximum objects of this class */
37    sizeof( API_Mutex_Control ), /* size of this object's control block */
38    false,                       /* true if the name is a string */
39    0                            /* maximum length of an object name */
40#if defined(RTEMS_MULTIPROCESSING)
41    ,
42    true,                        /* true if this is a global object class */
43    NULL                         /* Proxy extraction support callout */
44#endif
45  );
46}
47
48void _API_Mutex_Allocate(
49  API_Mutex_Control **the_mutex
50)
51{
52  API_Mutex_Control *mutex;
53
54  CORE_mutex_Attributes attr =  {
55    CORE_MUTEX_NESTING_ACQUIRES,
56    false,
57    CORE_MUTEX_DISCIPLINES_PRIORITY_INHERIT,
58    0
59  };
60
61  mutex = (API_Mutex_Control *)
62    _Objects_Allocate_unprotected( &_API_Mutex_Information );
63
64  _CORE_mutex_Initialize( &mutex->Mutex, NULL, &attr, false );
65
66  _Objects_Open_u32( &_API_Mutex_Information, &mutex->Object, 1 );
67
68  *the_mutex = mutex;
69}
Note: See TracBrowser for help on using the repository browser.