summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/coresemimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-01 11:38:47 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-06 09:08:21 +0200
commit8f9658187a46f3c3ee3d7c7b68491fab5175a8fd (patch)
treec1887c2441887909201698b8d16b8cb2e8598188 /cpukit/score/include/rtems/score/coresemimpl.h
parentscore: Simplify _Thread_queue_Do_flush() (diff)
downloadrtems-8f9658187a46f3c3ee3d7c7b68491fab5175a8fd.tar.bz2
score: Rework MP thread queue callout support
The thread queue implementation was heavily reworked to support SMP. This broke the multiprocessing support of the thread queues. This is fixed by this patch. A thread proxy is unblocked due to three reasons 1) timeout, 2) request satisfaction, and 3) extraction. In case 1) no MPCI message must be sent. This is ensured via the _Thread_queue_MP_callout_do_nothing() callout set during _Thread_MP_Allocate_proxy(). In case 2) and 3) an MPCI message must be sent. In case we interrupt the blocking operation during _Thread_queue_Enqueue_critical(), then this message must be sent by the blocking thread. For this the new fields Thread_Proxy_control::thread_queue_callout and Thread_Proxy_control::thread_queue_id are used. Delete the individual API MP callout types and use Thread_queue_MP_callout throughout. This type is only defined in multiprocessing configurations. Prefix the multiprocessing parameters with mp_ to ease code review. Multiprocessing specific parameters are optional due to use of a similar macro pattern. There is no overhead for non-multiprocessing configurations.
Diffstat (limited to 'cpukit/score/include/rtems/score/coresemimpl.h')
-rw-r--r--cpukit/score/include/rtems/score/coresemimpl.h94
1 files changed, 52 insertions, 42 deletions
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
index bde3e5b493..79d907c6b4 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -68,15 +68,6 @@ typedef enum {
#define CORE_SEMAPHORE_STATUS_LAST CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED
/**
- * The following type defines the callout which the API provides
- * to support global/multiprocessor operations on semaphores.
- */
-typedef void ( *CORE_semaphore_API_mp_support_callout )(
- Thread_Control *,
- Objects_Id
- );
-
-/**
* @brief Initialize the semaphore based on the parameters passed.
*
* This package is the implementation of the CORE Semaphore Handler.
@@ -102,28 +93,13 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy(
_Thread_queue_Destroy( &the_semaphore->Wait_queue );
}
-/**
- * @brief Surrender a unit to a semaphore.
- *
- * This routine frees a unit to the semaphore. If a task was blocked waiting
- * for a unit from this semaphore, then that task will be readied and the unit
- * given to that task. Otherwise, the unit will be returned to the semaphore.
- *
- * @param[in] the_semaphore is the semaphore to surrender
- * @param[in] id is the Id of the API level Semaphore object associated
- * with this instance of a SuperCore Semaphore
- * @param[in] api_semaphore_mp_support is the routine to invoke if the
- * thread unblocked is remote
- * @param[in] lock_context is a temporary variable used to contain the ISR
- * disable level cookie
- *
- * @retval an indication of whether the routine succeeded or failed
- */
-RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
- CORE_semaphore_Control *the_semaphore,
- Objects_Id id,
- CORE_semaphore_API_mp_support_callout api_semaphore_mp_support,
- ISR_lock_Context *lock_context
+RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Do_surrender(
+ CORE_semaphore_Control *the_semaphore,
+#if defined(RTEMS_MULTIPROCESSING)
+ Thread_queue_MP_callout mp_callout,
+ Objects_Id mp_id,
+#endif
+ ISR_lock_Context *lock_context
)
{
Thread_Control *the_thread;
@@ -138,23 +114,14 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
the_semaphore->operations
);
if ( the_thread != NULL ) {
-#if defined(RTEMS_MULTIPROCESSING)
- _Thread_Dispatch_disable();
-#endif
-
_Thread_queue_Extract_critical(
&the_semaphore->Wait_queue.Queue,
the_semaphore->operations,
the_thread,
+ mp_callout,
+ mp_id,
lock_context
);
-
-#if defined(RTEMS_MULTIPROCESSING)
- if ( !_Objects_Is_local_id( the_thread->Object.id ) )
- (*api_semaphore_mp_support) ( the_thread, id );
-
- _Thread_Dispatch_enable( _Per_CPU_Get() );
-#endif
} else {
if ( the_semaphore->count < UINT32_MAX )
the_semaphore->count += 1;
@@ -167,6 +134,49 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
return status;
}
+/**
+ * @brief Surrender a unit to a semaphore.
+ *
+ * This routine frees a unit to the semaphore. If a task was blocked waiting
+ * for a unit from this semaphore, then that task will be readied and the unit
+ * given to that task. Otherwise, the unit will be returned to the semaphore.
+ *
+ * @param[in] the_semaphore is the semaphore to surrender
+ * @param[in] mp_callout is the routine to invoke if the
+ * thread unblocked is remote
+ * @param[in] mp_id is the Id of the API level Semaphore object associated
+ * with this instance of a SuperCore Semaphore
+ * @param[in] lock_context is a temporary variable used to contain the ISR
+ * disable level cookie
+ *
+ * @retval an indication of whether the routine succeeded or failed
+ */
+#if defined(RTEMS_MULTIPROCESSING)
+ #define _CORE_semaphore_Surrender( \
+ the_semaphore, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ ) \
+ _CORE_semaphore_Do_surrender( \
+ the_semaphore, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ )
+#else
+ #define _CORE_semaphore_Surrender( \
+ the_semaphore, \
+ mp_callout, \
+ mp_id, \
+ lock_context \
+ ) \
+ _CORE_semaphore_Do_surrender( \
+ the_semaphore, \
+ lock_context \
+ )
+#endif
+
/* Must be a macro due to the multiprocessing dependent parameters */
#define _CORE_semaphore_Flush( \
the_semaphore, \