[rtems commit] RFS: Use self-contained recursive mutex

Sebastian Huber sebh at rtems.org
Fri Feb 2 14:23:03 UTC 2018


Module:    rtems
Branch:    master
Commit:    0940648f6fd85df7fe64a61c4eb3a041fe53f5a1
Changeset: http://git.rtems.org/rtems/commit/?id=0940648f6fd85df7fe64a61c4eb3a041fe53f5a1

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Dec 13 16:23:34 2017 +0100

RFS: Use self-contained recursive mutex

Update #2843.

---

 cpukit/include/rtems/confdefs.h            |  9 +--------
 cpukit/include/rtems/rfs/rtems-rfs-mutex.h | 25 ++++--------------------
 cpukit/libfs/src/rfs/rtems-rfs-mutex.c     | 31 ++----------------------------
 3 files changed, 7 insertions(+), 58 deletions(-)

diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index f988ea9..212b46c 100755
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -427,14 +427,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
 #if !defined(CONFIGURE_FILESYSTEM_ENTRY_RFS) && \
     defined(CONFIGURE_FILESYSTEM_RFS)
   #include <rtems/rtems-rfs.h>
-  #if !defined(CONFIGURE_MAXIMUM_RFS_MOUNTS)
-    #define CONFIGURE_MAXIMUM_RFS_MOUNTS 1
-  #endif
   #define CONFIGURE_FILESYSTEM_ENTRY_RFS \
     { RTEMS_FILESYSTEM_TYPE_RFS, rtems_rfs_rtems_initialise }
-  #define _CONFIGURE_SEMAPHORES_FOR_RFS CONFIGURE_MAXIMUM_RFS_MOUNTS
-#else
-  #define _CONFIGURE_SEMAPHORES_FOR_RFS 0
 #endif
 
 /**
@@ -453,8 +447,7 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
  */
 #define _CONFIGURE_SEMAPHORES_FOR_FILE_SYSTEMS \
     (_CONFIGURE_SEMAPHORES_FOR_FIFOS + \
-     _CONFIGURE_SEMAPHORES_FOR_NFS + \
-     _CONFIGURE_SEMAPHORES_FOR_RFS)
+     _CONFIGURE_SEMAPHORES_FOR_NFS)
 
 #ifdef CONFIGURE_INIT
 
diff --git a/cpukit/include/rtems/rfs/rtems-rfs-mutex.h b/cpukit/include/rtems/rfs/rtems-rfs-mutex.h
index 606fd53..57b58e5 100644
--- a/cpukit/include/rtems/rfs/rtems-rfs-mutex.h
+++ b/cpukit/include/rtems/rfs/rtems-rfs-mutex.h
@@ -29,13 +29,14 @@
 #if __rtems__
 #include <rtems.h>
 #include <rtems/error.h>
+#include <rtems/thread.h>
 #endif
 
 /**
  * RFS Mutex type.
  */
 #if __rtems__
-typedef rtems_id rtems_rfs_mutex;
+typedef rtems_recursive_mutex rtems_rfs_mutex;
 #else
 typedef uint32_t rtems_rfs_mutex; /* place holder */
 #endif
@@ -73,16 +74,7 @@ static inline int
 rtems_rfs_mutex_lock (rtems_rfs_mutex* mutex)
 {
 #if __rtems__
-  rtems_status_code sc = rtems_semaphore_obtain (*mutex, RTEMS_WAIT, 0);
-  if (sc != RTEMS_SUCCESSFUL)
-  {
-#if RTEMS_RFS_TRACE
-    if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
-      printf ("rtems-rfs: mutex: obtain failed: %s\n",
-              rtems_status_text (sc));
-#endif
-    return EIO;
-  }
+  rtems_recursive_mutex_lock(mutex);
 #endif
   return 0;
 }
@@ -99,16 +91,7 @@ static inline int
 rtems_rfs_mutex_unlock (rtems_rfs_mutex* mutex)
 {
 #if __rtems__
-  rtems_status_code sc = rtems_semaphore_release (*mutex);
-  if (sc != RTEMS_SUCCESSFUL)
-  {
-#if RTEMS_RFS_TRACE
-    if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
-      printf ("rtems-rfs: mutex: release failed: %s\n",
-              rtems_status_text (sc));
-#endif
-    return EIO;
-  }
+  rtems_recursive_mutex_unlock(mutex);
 #endif
   return 0;
 }
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-mutex.c b/cpukit/libfs/src/rfs/rtems-rfs-mutex.c
index a320d80..9c97c82 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-mutex.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-mutex.c
@@ -18,30 +18,11 @@
 
 #include <rtems/rfs/rtems-rfs-mutex.h>
 
-#if __rtems__
-/**
- * RTEMS_RFS Mutex Attributes
- */
-#define RTEMS_RFS_MUTEX_ATTRIBS \
-  (RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | \
-   RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL)
-#endif
-
 int
 rtems_rfs_mutex_create (rtems_rfs_mutex* mutex)
 {
 #if __rtems__
-  rtems_status_code sc;
-  sc = rtems_semaphore_create (rtems_build_name ('R', 'F', 'S', 'm'),
-                               1, RTEMS_RFS_MUTEX_ATTRIBS, 0,
-                               mutex);
-  if (sc != RTEMS_SUCCESSFUL)
-  {
-    if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
-      printf ("rtems-rfs: mutex: open failed: %s\n",
-              rtems_status_text (sc));
-    return EIO;
-  }
+  rtems_recursive_mutex_init(mutex, "RFS");
 #endif
   return 0;
 }
@@ -50,15 +31,7 @@ int
 rtems_rfs_mutex_destroy (rtems_rfs_mutex* mutex)
 {
 #if __rtems__
-  rtems_status_code sc;
-  sc = rtems_semaphore_delete (*mutex);
-  if (sc != RTEMS_SUCCESSFUL)
-  {
-    if (rtems_rfs_trace (RTEMS_RFS_TRACE_MUTEX))
-      printf ("rtems-rfs: mutex: close failed: %s\n",
-              rtems_status_text (sc));
-    return EIO;
-  }
+  rtems_recursive_mutex_destroy(mutex);
 #endif
   return 0;
 }




More information about the vc mailing list