[rtems commit] score: Add _Objects_Put_for_get_isr_disable()
Sebastian Huber
sebh at rtems.org
Fri Jun 7 15:02:23 UTC 2013
Module: rtems
Branch: master
Commit: 54e9216a0e646113a7e2f23a436731c0cf0fba62
Changeset: http://git.rtems.org/rtems/commit/?id=54e9216a0e646113a7e2f23a436731c0cf0fba62
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Jun 5 11:48:28 2013 +0200
score: Add _Objects_Put_for_get_isr_disable()
Provide SMP support. The ISR disable/enable is not enough to ensure
mutual exclusion for SMP configurations.
---
cpukit/posix/src/mutexlocksupp.c | 1 +
cpukit/rtems/src/semobtain.c | 2 ++
cpukit/score/inline/rtems/score/object.inl | 14 ++++++++++++++
cpukit/score/src/objectgetisr.c | 6 ++++++
4 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c
index 0a35e3c..22f6748 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -59,6 +59,7 @@ int _POSIX_Mutex_Lock_support(
timeout,
level
);
+ _Objects_Put_for_get_isr_disable( &the_mutex->Object );
return _POSIX_Mutex_Translate_core_mutex_return_code(
(CORE_mutex_Status) _Thread_Executing->Wait.return_code
);
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 14ed515..5b68974 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -60,6 +60,7 @@ rtems_status_code rtems_semaphore_obtain(
timeout,
level
);
+ _Objects_Put_for_get_isr_disable( &the_semaphore->Object );
return _Semaphore_Translate_core_mutex_return_code(
_Thread_Executing->Wait.return_code );
}
@@ -72,6 +73,7 @@ rtems_status_code rtems_semaphore_obtain(
timeout,
level
);
+ _Objects_Put_for_get_isr_disable( &the_semaphore->Object );
return _Semaphore_Translate_core_semaphore_return_code(
_Thread_Executing->Wait.return_code );
diff --git a/cpukit/score/inline/rtems/score/object.inl b/cpukit/score/inline/rtems/score/object.inl
index efdb23d..54365fa 100644
--- a/cpukit/score/inline/rtems/score/object.inl
+++ b/cpukit/score/inline/rtems/score/object.inl
@@ -375,4 +375,18 @@ RTEMS_INLINE_ROUTINE bool _Objects_Is_unlimited( uint32_t maximum )
((Objects_Maximum) ((maximum) & ~OBJECTS_UNLIMITED_OBJECTS))
#endif
+
+/**
+ * @brief Puts back an object obtained with _Objects_Get_isr_disable().
+ */
+RTEMS_INLINE_ROUTINE void _Objects_Put_for_get_isr_disable(
+ Objects_Control *the_object
+)
+{
+ (void) the_object;
+#if defined(RTEMS_SMP)
+ _Thread_Enable_dispatch();
+#endif
+}
+
/* end of include file */
diff --git a/cpukit/score/src/objectgetisr.c b/cpukit/score/src/objectgetisr.c
index 9eeee3c..56f7471 100644
--- a/cpukit/score/src/objectgetisr.c
+++ b/cpukit/score/src/objectgetisr.c
@@ -44,6 +44,9 @@ Objects_Control *_Objects_Get_isr_disable(
index = id - information->minimum_id + 1;
if ( information->maximum >= index ) {
+#if defined(RTEMS_SMP)
+ _Thread_Disable_dispatch();
+#endif
_ISR_Disable( level );
if ( (the_object = information->local_table[ index ]) != NULL ) {
*location = OBJECTS_LOCAL;
@@ -51,6 +54,9 @@ Objects_Control *_Objects_Get_isr_disable(
return the_object;
}
_ISR_Enable( level );
+#if defined(RTEMS_SMP)
+ _Thread_Enable_dispatch();
+#endif
*location = OBJECTS_ERROR;
return NULL;
}
More information about the vc
mailing list