From ceb0f6597c36fabbfcbdf0807fd87dd03a45cc5e Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 17 May 2016 16:03:46 +0200 Subject: score: Remove the Giant lock Update #2555. --- cpukit/score/src/threaddispatchdisablelevel.c | 140 -------------------------- 1 file changed, 140 deletions(-) delete mode 100644 cpukit/score/src/threaddispatchdisablelevel.c (limited to 'cpukit/score/src/threaddispatchdisablelevel.c') diff --git a/cpukit/score/src/threaddispatchdisablelevel.c b/cpukit/score/src/threaddispatchdisablelevel.c deleted file mode 100644 index 75b12bd358..0000000000 --- a/cpukit/score/src/threaddispatchdisablelevel.c +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file - * - * @brief Thread Dispatch Disable Functions - * - * @ingroup ScoreThread - */ - -/* - * COPYRIGHT (c) 1989-2011. - * 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. - */ - -#include -#include -#include -#include - -#define NO_OWNER_CPU NULL - -typedef struct { - SMP_lock_Control lock; - Per_CPU_Control *owner_cpu; - uint32_t nest_level; -} Giant_Control; - -static Giant_Control _Giant = { - .lock = SMP_LOCK_INITIALIZER("Giant"), - .owner_cpu = NO_OWNER_CPU, - .nest_level = 0 -}; - -static void _Giant_Do_acquire( Per_CPU_Control *cpu_self ) -{ - Giant_Control *giant = &_Giant; - - if ( giant->owner_cpu != cpu_self ) { - _SMP_lock_Acquire( &giant->lock, &cpu_self->Giant_lock_context ); - giant->owner_cpu = cpu_self; - giant->nest_level = 1; - } else { - ++giant->nest_level; - } -} - -static void _Giant_Do_release( Per_CPU_Control *cpu_self ) -{ - Giant_Control *giant = &_Giant; - - --giant->nest_level; - if ( giant->nest_level == 0 ) { - giant->owner_cpu = NO_OWNER_CPU; - _SMP_lock_Release( &giant->lock, &cpu_self->Giant_lock_context ); - } -} - -void _Giant_Drop( Per_CPU_Control *cpu_self ) -{ - Giant_Control *giant = &_Giant; - - _Assert( _ISR_Get_level() != 0 ); - - if ( giant->owner_cpu == cpu_self ) { - giant->nest_level = 0; - giant->owner_cpu = NO_OWNER_CPU; - _SMP_lock_Release( &giant->lock, &cpu_self->Giant_lock_context ); - } -} - -uint32_t _Thread_Dispatch_increment_disable_level( void ) -{ - ISR_Level isr_level; - uint32_t disable_level; - Per_CPU_Control *cpu_self; - - _ISR_Local_disable( isr_level ); - - /* - * We must obtain the processor after interrupts are disabled to prevent - * thread migration. - */ - cpu_self = _Per_CPU_Get(); - - _Giant_Do_acquire( cpu_self ); - - disable_level = cpu_self->thread_dispatch_disable_level; - _Profiling_Thread_dispatch_disable( cpu_self, disable_level ); - ++disable_level; - cpu_self->thread_dispatch_disable_level = disable_level; - - _ISR_Local_enable( isr_level ); - - return disable_level; -} - -uint32_t _Thread_Dispatch_decrement_disable_level( void ) -{ - ISR_Level isr_level; - uint32_t disable_level; - Per_CPU_Control *cpu_self; - - _ISR_Local_disable( isr_level ); - - cpu_self = _Per_CPU_Get(); - disable_level = cpu_self->thread_dispatch_disable_level; - _Assert( disable_level > 0); - --disable_level; - cpu_self->thread_dispatch_disable_level = disable_level; - - _Giant_Do_release( cpu_self ); - - _Profiling_Thread_dispatch_enable( cpu_self, disable_level ); - _ISR_Local_enable( isr_level ); - - return disable_level; -} - -void _Giant_Acquire( Per_CPU_Control *cpu_self ) -{ - ISR_Level isr_level; - - _ISR_Local_disable( isr_level ); - _Assert( _Thread_Dispatch_disable_level != 0 ); - _Giant_Do_acquire( cpu_self ); - _ISR_Local_enable( isr_level ); -} - -void _Giant_Release( Per_CPU_Control *cpu_self ) -{ - ISR_Level isr_level; - - _ISR_Local_disable( isr_level ); - _Assert( _Thread_Dispatch_disable_level != 0 ); - _Giant_Do_release( cpu_self ); - _ISR_Local_enable( isr_level ); -} -- cgit v1.2.3