source: rtems/cpukit/libfs/src/rfs/rtems-rfs-mutex.c @ 8d8f363

4.115
Last change on this file since 8d8f363 was a4097fdb, checked in by Sebastian Huber <sebastian.huber@…>, on 02/21/12 at 11:56:51

PR 2026/filesystem - Fix semaphore attributes

Semaphores of type RTEMS_SIMPLE_BINARY_SEMAPHORE are not suitable for a
mutex. Use RTEMS_BINARY_SEMAPHORE with RTEMS_INHERIT_PRIORITY instead.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10/**
11 * @file
12 *
13 * @ingroup rtems-rfs
14 *
15 * RTEMS File System Mutex.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/rfs/rtems-rfs-mutex.h>
23
24#if __rtems__
25/**
26 * RTEMS_RFS Mutex Attributes
27 */
28#define RTEMS_RFS_MUTEX_ATTRIBS \
29  (RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | \
30   RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL)
31#endif
32
33int
34rtems_rfs_mutex_create (rtems_rfs_mutex* mutex)
35{
36#if __rtems__
37  rtems_status_code sc;
38  sc = rtems_semaphore_create (rtems_build_name ('R', 'F', 'S', 'm'),
39                               1, RTEMS_RFS_MUTEX_ATTRIBS, 0,
40                               mutex);
41  if (sc != RTEMS_SUCCESSFUL)
42  {
43    if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
44      printf ("rtems-rfs: mutex: open failed: %s\n",
45              rtems_status_text (sc));
46    return EIO;
47  }
48#endif
49  return 0;
50}
51
52int
53rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex)
54{
55#if __rtems__
56  rtems_status_code sc;
57  sc = rtems_semaphore_delete (*mutex);
58  if (sc != RTEMS_SUCCESSFUL)
59  {
60    if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
61      printf ("rtems-rfs: mutex: close failed: %s\n",
62              rtems_status_text (sc));
63    return EIO;
64  }
65#endif
66  return 0;
67}
Note: See TracBrowser for help on using the repository browser.