[PATCH 10/12] cpukit/sapi: Resources for bdbuf SMP workaround

Ralf Kirchner ralf.kirchner at embedded-brains.de
Tue May 27 14:48:20 UTC 2014


Enabling and disabling preemption as done for single core in bdbuf will not work for SMP.
Thus as a temporary workaround use POSIX mutexes and POSIX condition variables for SMP instead of the combination of semaphores and preemption handling used for single core.
These will be allocated automatically.
---
 cpukit/sapi/include/confdefs.h |  143 ++++++++++++++++++++++++++++------------
 1 Datei geändert, 101 Zeilen hinzugefügt(+), 42 Zeilen entfernt(-)

diff --git a/cpukit/sapi/include/confdefs.h b/cpukit/sapi/include/confdefs.h
index 1c97d15..4b866f5 100644
--- a/cpukit/sapi/include/confdefs.h
+++ b/cpukit/sapi/include/confdefs.h
@@ -1520,16 +1520,55 @@ const rtems_libio_helper rtems_fs_init_helper =
     (CONFIGURE_BDBUF_TASK_STACK_SIZE <= CONFIGURE_MINIMUM_TASK_STACK_SIZE ? \
     0 : CONFIGURE_BDBUF_TASK_STACK_SIZE - CONFIGURE_MINIMUM_TASK_STACK_SIZE))
 
-  /*
-   *  Semaphores:
-   *    o disk lock
-   *    o bdbuf lock
-   *    o bdbuf sync lock
-   *    o bdbuf access condition
-   *    o bdbuf transfer condition
-   *    o bdbuf buffer condition
-   */
-  #define CONFIGURE_LIBBLOCK_SEMAPHORES 6
+  #if defined( RTEMS_SMP )
+    #if defined( RTEMS_POSIX_API )
+     /* The single core bdbuf implementation with enabling and disabling
+      * preemption will not work under SMP. Thus we need to use POSIX mutexes
+      * and POSIX condition variables as a workaround.
+      * Required POSIX mutexes and POSIX condition variables will be allocated
+      * automatically in confdefs.h if RTEMS_SMP and RTEMS_POSIX_API
+      * are #defined
+      */
+     #define CONFIGURE_BDBUF_SMP_WORKAROUND
+    #endif /* defined( RTEMS_POSIX_API ) */
+  #endif /* defined( RTEMS_SMP ) */
+
+  #ifdef CONFIGURE_BDBUF_SMP_WORKAROUND
+    /*
+     *  Semaphores:
+     *    o disk lock
+     */
+    #define CONFIGURE_LIBBLOCK_SEMAPHORES 1
+
+    /*
+     * POSIX Mutexes:
+     *  o bdbuf lock
+     *  o bdbuf sync lock
+     */
+    #define CONFIGURE_LIBBLOCK_POSIX_MUTEX_COUNT 2
+
+    /*
+     * POSIX Condition Variables:
+     *  o bdbuf access condition
+     *  o bdbuf transfer condition
+     *  o bdbuf buffer condition
+     */
+    #define CONFIGURE_LIBBLOCK_POSIX_CONDITION_VARIABLE_COUNT 3
+  #else
+    /*
+     *  Semaphores:
+     *    o disk lock
+     *    o bdbuf lock
+     *    o bdbuf sync lock
+     *    o bdbuf access condition
+     *    o bdbuf transfer condition
+     *    o bdbuf buffer condition
+     */
+    #define CONFIGURE_LIBBLOCK_SEMAPHORES 6
+
+    #define CONFIGURE_LIBBLOCK_POSIX_MUTEX_COUNT 0
+    #define CONFIGURE_LIBBLOCK_POSIX_CONDITION_VARIABLE_COUNT 0
+  #endif /* #ifdef CONFIGURE_BDBUF_SMP_WORKAROUND */
 
   #if defined(CONFIGURE_HAS_OWN_BDBUF_TABLE) || \
       defined(CONFIGURE_BDBUF_BUFFER_SIZE) || \
@@ -1540,6 +1579,8 @@ const rtems_libio_helper rtems_fs_init_helper =
   #define CONFIGURE_LIBBLOCK_TASKS 0
   #define CONFIGURE_LIBBLOCK_TASK_EXTRA_STACKS 0
   #define CONFIGURE_LIBBLOCK_SEMAPHORES 0
+  #define CONFIGURE_LIBBLOCK_POSIX_MUTEX_COUNT 0
+  #define CONFIGURE_LIBBLOCK_POSIX_CONDITION_VARIABLE_COUNT 0
 #endif /* CONFIGURE_APPLICATION_NEEDS_LIBBLOCK */
 
 #ifndef CONFIGURE_EXTRA_MPCI_RECEIVE_SERVER_STACK
@@ -2097,31 +2138,9 @@ const rtems_libio_helper rtems_fs_init_helper =
 
   #endif
 
-  #define CONFIGURE_MEMORY_FOR_POSIX \
-    ( CONFIGURE_MEMORY_FOR_POSIX_MUTEXES( CONFIGURE_MAXIMUM_POSIX_MUTEXES + \
-          CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_MUTEXES) + \
-      CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES( \
-          CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES + \
-          CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_CONDITION_VARIABLES) + \
-      CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( \
-          CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ) + \
-      CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( \
-          CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ) + \
-      CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUE_DESCRIPTORS( \
-          CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS ) + \
-      CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \
-          CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ) + \
-      CONFIGURE_MEMORY_FOR_POSIX_BARRIERS(CONFIGURE_MAXIMUM_POSIX_BARRIERS) + \
-      CONFIGURE_MEMORY_FOR_POSIX_SPINLOCKS( \
-          CONFIGURE_MAXIMUM_POSIX_SPINLOCKS ) + \
-      CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( \
-          CONFIGURE_MAXIMUM_POSIX_RWLOCKS ) + \
-      CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ) \
-     )
 #else
 
   #define CONFIGURE_MAXIMUM_POSIX_THREADS         0
-  #define CONFIGURE_MEMORY_FOR_POSIX              0
 
 #endif    /* RTEMS_POSIX_API */
 
@@ -2213,6 +2232,52 @@ const rtems_libio_helper rtems_fs_init_helper =
      CONFIGURE_MAXIMUM_ADA_TASKS + \
      CONFIGURE_MAXIMUM_GOROUTINES)
 
+#ifdef RTEMS_POSIX_API
+  /**
+  * This macro provides summation of the POSIX Mutexes.
+  */
+  #define CONFIGURE_POSIX_MUTEX_COUNT \
+    ( CONFIGURE_MAXIMUM_POSIX_MUTEXES + \
+      CONFIGURE_GNAT_MUTEXES + \
+      CONFIGURE_MAXIMUM_ADA_TASKS + \
+      CONFIGURE_MAXIMUM_FAKE_ADA_TASKS + \
+      CONFIGURE_GO_INIT_MUTEXES + \
+      CONFIGURE_MAXIMUM_GO_CHANNELS + \
+      CONFIGURE_LIBBLOCK_POSIX_MUTEX_COUNT )
+
+  /**
+  * This macro provides summation of the POSIX Condition Variables
+  */
+  #define CONFIGURE_POSIX_CONDITION_VARIABLE_COUNT \
+    ( CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES + \
+      CONFIGURE_MAXIMUM_ADA_TASKS + \
+      CONFIGURE_MAXIMUM_FAKE_ADA_TASKS + \
+      CONFIGURE_GO_INIT_CONDITION_VARIABLES + \
+      CONFIGURE_MAXIMUM_GO_CHANNELS + \
+      CONFIGURE_LIBBLOCK_POSIX_CONDITION_VARIABLE_COUNT )
+
+  #define CONFIGURE_MEMORY_FOR_POSIX \
+    ( CONFIGURE_MEMORY_FOR_POSIX_MUTEXES( CONFIGURE_POSIX_MUTEX_COUNT ) + \
+      CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES( \
+      CONFIGURE_POSIX_CONDITION_VARIABLE_COUNT ) + \
+      CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS( \
+      CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ) + \
+      CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( \
+      CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ) + \
+      CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUE_DESCRIPTORS( \
+      CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUE_DESCRIPTORS ) + \
+      CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \
+      CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ) + \
+      CONFIGURE_MEMORY_FOR_POSIX_BARRIERS(CONFIGURE_MAXIMUM_POSIX_BARRIERS) + \
+      CONFIGURE_MEMORY_FOR_POSIX_SPINLOCKS( \
+      CONFIGURE_MAXIMUM_POSIX_SPINLOCKS ) + \
+      CONFIGURE_MEMORY_FOR_POSIX_RWLOCKS( \
+      CONFIGURE_MAXIMUM_POSIX_RWLOCKS ) + \
+      CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ) )
+#else
+  #define CONFIGURE_MEMORY_FOR_POSIX 0
+#endif    /* RTEMS_POSIX_API */
+
 /*
  *  Calculate the RAM size based on the maximum number of objects configured.
  */
@@ -2570,12 +2635,8 @@ const rtems_libio_helper rtems_fs_init_helper =
      */
     posix_api_configuration_table Configuration_POSIX_API = {
       CONFIGURE_POSIX_THREADS,
-      CONFIGURE_MAXIMUM_POSIX_MUTEXES + CONFIGURE_GNAT_MUTEXES +
-        CONFIGURE_MAXIMUM_ADA_TASKS + CONFIGURE_MAXIMUM_FAKE_ADA_TASKS +
-        CONFIGURE_GO_INIT_MUTEXES + CONFIGURE_MAXIMUM_GO_CHANNELS,
-      CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES +
-        CONFIGURE_MAXIMUM_ADA_TASKS + CONFIGURE_MAXIMUM_FAKE_ADA_TASKS +
-        CONFIGURE_GO_INIT_CONDITION_VARIABLES + CONFIGURE_MAXIMUM_GO_CHANNELS,
+      CONFIGURE_POSIX_MUTEX_COUNT,
+      CONFIGURE_POSIX_CONDITION_VARIABLE_COUNT,
       CONFIGURE_MAXIMUM_POSIX_TIMERS,
       CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS,
       CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES,
@@ -2810,11 +2871,9 @@ const rtems_libio_helper rtems_fs_init_helper =
 
 #ifdef RTEMS_POSIX_API
     /* POSIX API Pieces */
-    CONFIGURE_MEMORY_FOR_POSIX_MUTEXES( CONFIGURE_MAXIMUM_POSIX_MUTEXES +
-      CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_MUTEXES),
+    CONFIGURE_MEMORY_FOR_POSIX_MUTEXES( CONFIGURE_POSIX_MUTEX_COUNT ),
     CONFIGURE_MEMORY_FOR_POSIX_CONDITION_VARIABLES(
-      CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES +
-      CONFIGURE_MAXIMUM_GO_CHANNELS + CONFIGURE_GO_INIT_CONDITION_VARIABLES),
+      CONFIGURE_POSIX_CONDITION_VARIABLE_COUNT ),
     CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS(
       CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ),
     CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES(
-- 
1.7.10.4




More information about the devel mailing list