[rtems commit] score: Delete _CORE_semaphore_Seize()

Sebastian Huber sebh at rtems.org
Wed May 20 07:12:03 UTC 2015


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Sat May  2 14:02:20 2015 +0200

score: Delete _CORE_semaphore_Seize()

Rename _CORE_semaphore_Seize_isr_disable() to _CORE_semaphore_Seize().

---

 cpukit/posix/src/semaphorewaitsupp.c           | 11 ++--
 cpukit/rtems/src/semobtain.c                   |  2 +-
 cpukit/score/Makefile.am                       |  2 +-
 cpukit/score/include/rtems/score/coresemimpl.h | 30 +----------
 cpukit/score/src/coresemseize.c                | 72 --------------------------
 cpukit/score/src/mpci.c                        |  7 +--
 6 files changed, 15 insertions(+), 109 deletions(-)

diff --git a/cpukit/posix/src/semaphorewaitsupp.c b/cpukit/posix/src/semaphorewaitsupp.c
index cd572c4..8b36561 100644
--- a/cpukit/posix/src/semaphorewaitsupp.c
+++ b/cpukit/posix/src/semaphorewaitsupp.c
@@ -40,8 +40,13 @@ int _POSIX_Semaphore_Wait_support(
   POSIX_Semaphore_Control *the_semaphore;
   Objects_Locations        location;
   Thread_Control          *executing;
+  ISR_lock_Context         lock_context;
 
-  the_semaphore = _POSIX_Semaphore_Get( sem, &location );
+  the_semaphore = _POSIX_Semaphore_Get_interrupt_disable(
+    sem,
+    &location,
+    &lock_context
+  );
   switch ( location ) {
 
     case OBJECTS_LOCAL:
@@ -51,9 +56,9 @@ int _POSIX_Semaphore_Wait_support(
         executing,
         the_semaphore->Object.id,
         blocking,
-        timeout
+        timeout,
+        &lock_context
       );
-      _Objects_Put( &the_semaphore->Object );
 
       if ( !executing->Wait.return_code )
         return 0;
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index ca13bea..46d1b82 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -93,7 +93,7 @@ rtems_status_code rtems_semaphore_obtain(
       }
 
       /* must be a counting semaphore */
-      _CORE_semaphore_Seize_isr_disable(
+      _CORE_semaphore_Seize(
         &the_semaphore->Core_control.semaphore,
         executing,
         id,
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index 6d4414c..d8ec8e1 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -177,7 +177,7 @@ libscore_a_SOURCES += src/corerwlock.c src/corerwlockobtainread.c \
 endif
 
 ## CORE_SEMAPHORE_C_FILES
-libscore_a_SOURCES += src/coresem.c src/coresemflush.c src/coresemseize.c \
+libscore_a_SOURCES += src/coresem.c src/coresemflush.c \
     src/coresemsurrender.c
 
 ## CORE_SPINLOCK_C_FILES
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
index 75851ee..7e967ed 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -33,10 +33,6 @@ extern "C" {
  */
 /**@{**/
 
-#if defined(RTEMS_POSIX_API) || defined(RTEMS_MULTIPROCESSING)
-  #define RTEMS_SCORE_CORESEM_ENABLE_SEIZE_BODY
-#endif
-
 /**
  *  Core Semaphore handler return statuses.
  */
@@ -105,30 +101,6 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy(
   _Thread_queue_Destroy( &the_semaphore->Wait_queue );
 }
 
-#if defined(RTEMS_SCORE_CORESEM_ENABLE_SEIZE_BODY)
-  /**
-   *  This routine attempts to receive a unit from @a the_semaphore.
-   *  If a unit is available or if the wait flag is false, then the routine
-   *  returns.  Otherwise, the calling task is blocked until a unit becomes
-   *  available.
-   *
-   *  @param[in] the_semaphore is the semaphore to seize
-   *  @param[in,out] executing The currently executing thread.
-   *  @param[in] id is the Id of the API level Semaphore object associated
-   *         with this instance of a SuperCore Semaphore
-   *  @param[in] wait indicates if the caller is willing to block
-   *  @param[in] timeout is the number of ticks the calling thread is willing
-   *         to wait if @a wait is true.
-   */
-  void _CORE_semaphore_Seize(
-    CORE_semaphore_Control  *the_semaphore,
-    Thread_Control          *executing,
-    Objects_Id               id,
-    bool                     wait,
-    Watchdog_Interval        timeout
-  );
-#endif
-
 /**
  *  @brief Surrender a unit to a semaphore.
  *
@@ -219,7 +191,7 @@ RTEMS_INLINE_ROUTINE uint32_t  _CORE_semaphore_Get_count(
  *
  * @note There is currently no MACRO version of this routine.
  */
-RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
+RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize(
   CORE_semaphore_Control  *the_semaphore,
   Thread_Control          *executing,
   Objects_Id               id,
diff --git a/cpukit/score/src/coresemseize.c b/cpukit/score/src/coresemseize.c
deleted file mode 100644
index 6ecf2c4..0000000
--- a/cpukit/score/src/coresemseize.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * @file
- *
- * @brief Core Semaphore Seize
- *
- * @ingroup ScoreSemaphore
- */
-
-/*
- *  COPYRIGHT (c) 1989-2008.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/system.h>
-#include <rtems/score/isr.h>
-#include <rtems/score/coresemimpl.h>
-#include <rtems/score/thread.h>
-
-#if defined(RTEMS_SCORE_CORESEM_ENABLE_SEIZE_BODY)
-
-void _CORE_semaphore_Seize(
-  CORE_semaphore_Control *the_semaphore,
-  Thread_Control         *executing,
-  Objects_Id              id,
-  bool                    wait,
-  Watchdog_Interval       timeout
-)
-{
-  ISR_lock_Context lock_context;
-
-  executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
-  _Thread_queue_Acquire( &the_semaphore->Wait_queue, &lock_context );
-  if ( the_semaphore->count != 0 ) {
-    the_semaphore->count -= 1;
-    _Thread_queue_Release( &the_semaphore->Wait_queue, &lock_context );
-    return;
-  }
-
-  /*
-   *  If the semaphore was not available and the caller was not willing
-   *  to block, then return immediately with a status indicating that
-   *  the semaphore was not available and the caller never blocked.
-   */
-  if ( !wait ) {
-    _Thread_queue_Release( &the_semaphore->Wait_queue, &lock_context );
-    executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
-    return;
-  }
-
-  /*
-   *  If the semaphore is not available and the caller is willing to
-   *  block, then we now block the caller with optional timeout.
-   */
-  executing->Wait.id = id;
-  _Thread_queue_Enqueue_critical(
-    &the_semaphore->Wait_queue,
-    executing,
-    STATES_WAITING_FOR_SEMAPHORE,
-    timeout,
-    CORE_SEMAPHORE_TIMEOUT,
-    &lock_context
-  );
-}
-#endif
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index 6b3bc7f..2b1f6ff 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -283,6 +283,7 @@ Thread _MPCI_Receive_server(
   MP_packet_Prefix         *the_packet;
   MPCI_Packet_processor     the_function;
   Thread_Control           *executing;
+  ISR_lock_Context          lock_context;
 
   executing = _Thread_Get_executing();
 
@@ -290,15 +291,15 @@ Thread _MPCI_Receive_server(
 
     executing->receive_packet = NULL;
 
-    _Thread_Disable_dispatch();
+    _ISR_lock_ISR_disable( &lock_context );
     _CORE_semaphore_Seize(
       &_MPCI_Semaphore,
       executing,
       0,
       true,
-      WATCHDOG_NO_TIMEOUT
+      WATCHDOG_NO_TIMEOUT,
+      &lock_context
     );
-    _Thread_Enable_dispatch();
 
     for ( ; ; ) {
       the_packet = _MPCI_Receive_packet();




More information about the vc mailing list