[rtems commit] score: Simplify Giant lock
Sebastian Huber
sebh at rtems.org
Tue Apr 22 07:30:13 UTC 2014
Module: rtems
Branch: master
Commit: 4c23fa4b7d98015aa82a6974451e47784049133b
Changeset: http://git.rtems.org/rtems/commit/?id=4c23fa4b7d98015aa82a6974451e47784049133b
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Tue Apr 22 07:46:47 2014 +0200
score: Simplify Giant lock
---
cpukit/score/src/threaddispatchdisablelevel.c | 16 +++++++---------
1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/cpukit/score/src/threaddispatchdisablelevel.c b/cpukit/score/src/threaddispatchdisablelevel.c
index a53c054..1a17aee 100644
--- a/cpukit/score/src/threaddispatchdisablelevel.c
+++ b/cpukit/score/src/threaddispatchdisablelevel.c
@@ -20,11 +20,11 @@
#include <rtems/score/profiling.h>
#include <rtems/score/sysstate.h>
-#define NO_OWNER_CPU 0xffffffffU
+#define NO_OWNER_CPU NULL
typedef struct {
SMP_lock_Control lock;
- uint32_t owner_cpu;
+ Per_CPU_Control *owner_cpu;
uint32_t nest_level;
} Giant_Control;
@@ -37,11 +37,10 @@ static Giant_Control _Giant = {
static void _Giant_Do_acquire( Per_CPU_Control *self_cpu )
{
Giant_Control *giant = &_Giant;
- uint32_t self_cpu_index = _Per_CPU_Get_index( self_cpu );
- if ( giant->owner_cpu != self_cpu_index ) {
+ if ( giant->owner_cpu != self_cpu ) {
_SMP_lock_Acquire( &giant->lock, &self_cpu->Giant_lock_context );
- giant->owner_cpu = self_cpu_index;
+ giant->owner_cpu = self_cpu;
giant->nest_level = 1;
} else {
++giant->nest_level;
@@ -62,11 +61,10 @@ static void _Giant_Do_release( Per_CPU_Control *self_cpu )
void _Giant_Drop( Per_CPU_Control *self_cpu )
{
Giant_Control *giant = &_Giant;
- uint32_t self_cpu_index = _Per_CPU_Get_index( self_cpu );
_Assert( _ISR_Get_level() != 0 );
- if ( giant->owner_cpu == self_cpu_index ) {
+ if ( giant->owner_cpu == self_cpu ) {
giant->nest_level = 0;
giant->owner_cpu = NO_OWNER_CPU;
_SMP_lock_Release( &giant->lock, &self_cpu->Giant_lock_context );
@@ -113,7 +111,7 @@ uint32_t _Thread_Dispatch_decrement_disable_level( void )
self_cpu->thread_dispatch_disable_level = disable_level;
_Giant_Do_release( self_cpu );
- _Assert( disable_level != 0 || _Giant.owner_cpu == NO_OWNER_CPU );
+ _Assert( disable_level != 0 || _Giant.owner_cpu != self_cpu );
_Profiling_Thread_dispatch_enable( self_cpu, disable_level );
_ISR_Enable_without_giant( isr_level );
@@ -146,7 +144,7 @@ bool _Debug_Is_owner_of_giant( void )
{
Giant_Control *giant = &_Giant;
- return giant->owner_cpu == _SMP_Get_current_processor()
+ return giant->owner_cpu == _Per_CPU_Get_snapshot()
|| !_System_state_Is_up( _System_state_Get() );
}
#endif
More information about the vc
mailing list