summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-08-22 10:58:34 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-09-08 09:55:27 +0200
commite41308eab8ae4505844d8e499664424f8c7f2bd1 (patch)
tree7dffe5edacd3f245ba5ef3b64b431b7e4c74c454 /cpukit/score/src
parentscore: Simplify thread queue acquire/release (diff)
downloadrtems-e41308eab8ae4505844d8e499664424f8c7f2bd1.tar.bz2
score: Introduce Thread_queue_Lock_context
Introduce Thread_queue_Lock_context to contain the context necessary for thread queue lock and thread wait lock acquire/release operations to reduce the Thread_Control size.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/apimutexlock.c2
-rw-r--r--cpukit/score/src/apimutexunlock.c2
-rw-r--r--cpukit/score/src/condition.c26
-rw-r--r--cpukit/score/src/coremsgbroadcast.c2
-rw-r--r--cpukit/score/src/coremutexseize.c2
-rw-r--r--cpukit/score/src/futex.c6
-rw-r--r--cpukit/score/src/mpci.c4
-rw-r--r--cpukit/score/src/mutex.c6
-rw-r--r--cpukit/score/src/semaphore.c6
-rw-r--r--cpukit/score/src/threadqenqueue.c52
-rw-r--r--cpukit/score/src/threadqflush.c6
-rw-r--r--cpukit/score/src/threadrestart.c2
12 files changed, 60 insertions, 56 deletions
diff --git a/cpukit/score/src/apimutexlock.c b/cpukit/score/src/apimutexlock.c
index f69cfdea64..cf90a76f1e 100644
--- a/cpukit/score/src/apimutexlock.c
+++ b/cpukit/score/src/apimutexlock.c
@@ -32,7 +32,7 @@ void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
_Thread_Set_life_protection( THREAD_LIFE_PROTECTED );
_Thread_queue_Context_initialize( &queue_context );
- _ISR_lock_ISR_disable( &queue_context.Lock_context );
+ _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
_Thread_queue_Context_set_no_timeout( &queue_context );
_CORE_recursive_mutex_Seize(
&the_mutex->Mutex,
diff --git a/cpukit/score/src/apimutexunlock.c b/cpukit/score/src/apimutexunlock.c
index 67188db144..f04e47a46e 100644
--- a/cpukit/score/src/apimutexunlock.c
+++ b/cpukit/score/src/apimutexunlock.c
@@ -32,7 +32,7 @@ void _API_Mutex_Unlock( API_Mutex_Control *the_mutex )
restore_thread_life_protection = the_mutex->Mutex.nest_level == 0;
_Thread_queue_Context_initialize( &queue_context );
- _ISR_lock_ISR_disable( &queue_context.Lock_context );
+ _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
_CORE_recursive_mutex_Surrender(
&the_mutex->Mutex,
_Thread_Executing,
diff --git a/cpukit/score/src/condition.c b/cpukit/score/src/condition.c
index b9e14adce8..36ef98949b 100644
--- a/cpukit/score/src/condition.c
+++ b/cpukit/score/src/condition.c
@@ -63,7 +63,7 @@ static Thread_Control *_Condition_Queue_acquire_critical(
_Thread_queue_Queue_acquire_critical(
&condition->Queue.Queue,
&executing->Potpourri_stats,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
return executing;
@@ -76,7 +76,7 @@ static void _Condition_Queue_release(
{
_Thread_queue_Queue_release(
&condition->Queue.Queue,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
}
@@ -91,7 +91,9 @@ static Per_CPU_Control *_Condition_Do_wait(
condition = _Condition_Get( _condition );
executing = _Condition_Queue_acquire_critical( condition, queue_context );
- cpu_self = _Thread_Dispatch_disable_critical( &queue_context->Lock_context );
+ cpu_self = _Thread_Dispatch_disable_critical(
+ &queue_context->Lock_context.Lock_context
+ );
_Thread_queue_Context_set_expected_level( queue_context, 2 );
_Thread_queue_Enqueue_critical(
@@ -114,7 +116,7 @@ void _Condition_Wait(
Per_CPU_Control *cpu_self;
_Thread_queue_Context_initialize( &queue_context );
- _ISR_lock_ISR_disable( &queue_context.Lock_context );
+ _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
_Thread_queue_Context_set_no_timeout( &queue_context );
cpu_self = _Condition_Do_wait(
_condition,
@@ -139,15 +141,15 @@ int _Condition_Wait_timed(
Watchdog_Interval ticks;
_Thread_queue_Context_initialize( &queue_context );
- _ISR_lock_ISR_disable( &queue_context.Lock_context );
+ _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
switch ( _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ) ) {
case TOD_ABSOLUTE_TIMEOUT_INVALID:
- _ISR_lock_ISR_enable( &queue_context.Lock_context );
+ _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
return EINVAL;
case TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST:
case TOD_ABSOLUTE_TIMEOUT_IS_NOW:
- _ISR_lock_ISR_enable( &queue_context.Lock_context );
+ _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
return ETIMEDOUT;
default:
break;
@@ -175,7 +177,7 @@ void _Condition_Wait_recursive(
unsigned int nest_level;
_Thread_queue_Context_initialize( &queue_context );
- _ISR_lock_ISR_disable( &queue_context.Lock_context );
+ _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
_Thread_queue_Context_set_no_timeout( &queue_context );
cpu_self = _Condition_Do_wait( _condition, &queue_context );
@@ -201,15 +203,15 @@ int _Condition_Wait_recursive_timed(
Watchdog_Interval ticks;
_Thread_queue_Context_initialize( &queue_context );
- _ISR_lock_ISR_disable( &queue_context.Lock_context );
+ _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
switch ( _TOD_Absolute_timeout_to_ticks( abstime, CLOCK_REALTIME, &ticks ) ) {
case TOD_ABSOLUTE_TIMEOUT_INVALID:
- _ISR_lock_ISR_enable( &queue_context.Lock_context );
+ _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
return EINVAL;
case TOD_ABSOLUTE_TIMEOUT_IS_IN_PAST:
case TOD_ABSOLUTE_TIMEOUT_IS_NOW:
- _ISR_lock_ISR_enable( &queue_context.Lock_context );
+ _ISR_lock_ISR_enable( &queue_context.Lock_context.Lock_context );
return ETIMEDOUT;
default:
break;
@@ -261,7 +263,7 @@ static void _Condition_Wake( struct _Condition_Control *_condition, int count )
condition = _Condition_Get( _condition );
_Thread_queue_Context_initialize( &context.Base );
- _ISR_lock_ISR_disable( &context.Base.Lock_context );
+ _ISR_lock_ISR_disable( &context.Base.Lock_context.Lock_context );
_Condition_Queue_acquire_critical( condition, &context.Base );
/*
diff --git a/cpukit/score/src/coremsgbroadcast.c b/cpukit/score/src/coremsgbroadcast.c
index f7579c2d98..ed92dbc620 100644
--- a/cpukit/score/src/coremsgbroadcast.c
+++ b/cpukit/score/src/coremsgbroadcast.c
@@ -33,7 +33,7 @@ Status_Control _CORE_message_queue_Broadcast(
uint32_t number_broadcasted;
if ( size > the_message_queue->maximum_message_size ) {
- _ISR_lock_ISR_enable( &queue_context->Lock_context );
+ _ISR_lock_ISR_enable( &queue_context->Lock_context.Lock_context );
return STATUS_MESSAGE_INVALID_SIZE;
}
diff --git a/cpukit/score/src/coremutexseize.c b/cpukit/score/src/coremutexseize.c
index cfefc50333..89b5c56a83 100644
--- a/cpukit/score/src/coremutexseize.c
+++ b/cpukit/score/src/coremutexseize.c
@@ -57,7 +57,7 @@ Status_Control _CORE_mutex_Seize_slow(
#if defined(RTEMS_SMP)
_Thread_queue_Context_set_expected_level( queue_context, 1 );
#else
- _ISR_lock_ISR_disable( &queue_context->Lock_context );
+ _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
_CORE_mutex_Acquire_critical( the_mutex, queue_context );
_Thread_queue_Context_set_expected_level( queue_context, 2 );
#endif
diff --git a/cpukit/score/src/futex.c b/cpukit/score/src/futex.c
index 840101a703..1989445c73 100644
--- a/cpukit/score/src/futex.c
+++ b/cpukit/score/src/futex.c
@@ -55,12 +55,12 @@ static Thread_Control *_Futex_Queue_acquire(
{
Thread_Control *executing;
- _ISR_lock_ISR_disable( &queue_context->Lock_context );
+ _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
executing = _Thread_Executing;
_Thread_queue_Queue_acquire_critical(
&futex->Queue.Queue,
&executing->Potpourri_stats,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
return executing;
@@ -73,7 +73,7 @@ static void _Futex_Queue_release(
{
_Thread_queue_Queue_release(
&futex->Queue.Queue,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
}
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index a562b29cbd..87d90a63f9 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -335,7 +335,7 @@ void _MPCI_Receive_server(
executing->receive_packet = NULL;
- _ISR_lock_ISR_disable( &queue_context.Lock_context );
+ _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
_CORE_semaphore_Seize(
&_MPCI_Semaphore,
MPCI_SEMAPHORE_TQ_OPERATIONS,
@@ -375,7 +375,7 @@ void _MPCI_Announce ( void )
{
Thread_queue_Context queue_context;
- _ISR_lock_ISR_disable( &queue_context.Lock_context );
+ _ISR_lock_ISR_disable( &queue_context.Lock_context.Lock_context );
(void) _CORE_semaphore_Surrender(
&_MPCI_Semaphore,
MPCI_SEMAPHORE_TQ_OPERATIONS,
diff --git a/cpukit/score/src/mutex.c b/cpukit/score/src/mutex.c
index b1311c0c53..bfa36ff994 100644
--- a/cpukit/score/src/mutex.c
+++ b/cpukit/score/src/mutex.c
@@ -78,12 +78,12 @@ static Thread_Control *_Mutex_Queue_acquire(
{
Thread_Control *executing;
- _ISR_lock_ISR_disable( &queue_context->Lock_context );
+ _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
executing = _Thread_Executing;
_Thread_queue_Queue_acquire_critical(
&mutex->Queue.Queue,
&executing->Potpourri_stats,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
return executing;
@@ -96,7 +96,7 @@ static void _Mutex_Queue_release(
{
_Thread_queue_Queue_release(
&mutex->Queue.Queue,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
}
diff --git a/cpukit/score/src/semaphore.c b/cpukit/score/src/semaphore.c
index 72cb1c796d..be7d685105 100644
--- a/cpukit/score/src/semaphore.c
+++ b/cpukit/score/src/semaphore.c
@@ -62,12 +62,12 @@ static Thread_Control *_Semaphore_Queue_acquire(
{
Thread_Control *executing;
- _ISR_lock_ISR_disable( &queue_context->Lock_context );
+ _ISR_lock_ISR_disable( &queue_context->Lock_context.Lock_context );
executing = _Thread_Executing;
_Thread_queue_Queue_acquire_critical(
&sem->Queue.Queue,
&executing->Potpourri_stats,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
return executing;
@@ -80,7 +80,7 @@ static void _Semaphore_Queue_release(
{
_Thread_queue_Queue_release(
&sem->Queue.Queue,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
}
diff --git a/cpukit/score/src/threadqenqueue.c b/cpukit/score/src/threadqenqueue.c
index 81b3948293..f16dff0005 100644
--- a/cpukit/score/src/threadqenqueue.c
+++ b/cpukit/score/src/threadqenqueue.c
@@ -184,10 +184,10 @@ static void _Thread_queue_Path_release( Thread_queue_Path *path )
link = THREAD_QUEUE_LINK_OF_PATH_NODE( node );
- if ( link->Queue_context.Wait.queue == NULL ) {
+ if ( link->Lock_context.Wait.queue == NULL ) {
_Thread_Wait_release_default_critical(
link->owner,
- &link->Queue_context.Lock_context
+ &link->Lock_context.Lock_context
);
node = _Chain_Previous( node );
@@ -199,14 +199,14 @@ static void _Thread_queue_Path_release( Thread_queue_Path *path )
while ( head != node ) {
/* The other links have an owner which waits on a thread queue */
link = THREAD_QUEUE_LINK_OF_PATH_NODE( node );
- _Assert( link->Queue_context.Wait.queue != NULL );
+ _Assert( link->Lock_context.Wait.queue != NULL );
_Thread_queue_Link_remove( link );
_Thread_Wait_release_queue_critical(
- link->Queue_context.Wait.queue,
- &link->Queue_context
+ link->Lock_context.Wait.queue,
+ &link->Lock_context
);
- _Thread_Wait_remove_request( link->owner, &link->Queue_context );
+ _Thread_Wait_remove_request( link->owner, &link->Lock_context );
node = _Chain_Previous( node );
#if defined(RTEMS_DEBUG)
@@ -253,7 +253,7 @@ static bool _Thread_queue_Path_acquire(
_RBTree_Initialize_node( &path->Start.Registry_node );
_Chain_Initialize_node( &path->Start.Path_node );
- _Thread_queue_Context_initialize( &path->Start.Queue_context );
+ _Chain_Initialize_node( &path->Start.Lock_context.Wait.Gate.Node );
link = &path->Start;
do {
@@ -262,37 +262,37 @@ static bool _Thread_queue_Path_acquire(
_Thread_Wait_acquire_default_critical(
owner,
- &link->Queue_context.Lock_context
+ &link->Lock_context.Lock_context
);
target = owner->Wait.queue;
- link->Queue_context.Wait.queue = target;
+ link->Lock_context.Wait.queue = target;
if ( target != NULL ) {
if ( _Thread_queue_Link_add( link, queue, target ) ) {
_Thread_queue_Gate_add(
&owner->Wait.Lock.Pending_requests,
- &link->Queue_context.Wait.Gate
+ &link->Lock_context.Wait.Gate
);
_Thread_Wait_release_default_critical(
owner,
- &link->Queue_context.Lock_context
+ &link->Lock_context.Lock_context
);
- _Thread_Wait_acquire_queue_critical( target, &link->Queue_context );
+ _Thread_Wait_acquire_queue_critical( target, &link->Lock_context );
- if ( link->Queue_context.Wait.queue == NULL ) {
+ if ( link->Lock_context.Wait.queue == NULL ) {
_Thread_queue_Link_remove( link );
- _Thread_Wait_release_queue_critical( target, &link->Queue_context );
+ _Thread_Wait_release_queue_critical( target, &link->Lock_context );
_Thread_Wait_acquire_default_critical(
owner,
- &link->Queue_context.Lock_context
+ &link->Lock_context.Lock_context
);
- _Thread_Wait_remove_request_locked( owner, &link->Queue_context );
+ _Thread_Wait_remove_request_locked( owner, &link->Lock_context );
_Assert( owner->Wait.queue == NULL );
return true;
}
} else {
- link->Queue_context.Wait.queue = NULL;
+ link->Lock_context.Wait.queue = NULL;
_Thread_queue_Path_release( path );
return false;
}
@@ -359,7 +359,7 @@ void _Thread_queue_Enqueue_critical(
if ( !_Thread_queue_Path_acquire( the_thread, queue, &path ) ) {
_Thread_Wait_restore_default( the_thread );
- _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+ _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
_Thread_Wait_tranquilize( the_thread );
( *queue_context->deadlock_callout )( the_thread );
return;
@@ -371,8 +371,10 @@ void _Thread_queue_Enqueue_critical(
the_thread->Wait.return_code = STATUS_SUCCESSFUL;
_Thread_Wait_flags_set( the_thread, THREAD_QUEUE_INTEND_TO_BLOCK );
- cpu_self = _Thread_Dispatch_disable_critical( &queue_context->Lock_context );
- _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+ cpu_self = _Thread_Dispatch_disable_critical(
+ &queue_context->Lock_context.Lock_context
+ );
+ _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
if (
cpu_self->thread_dispatch_disable_level
@@ -544,7 +546,7 @@ void _Thread_queue_Extract_critical(
unblock,
queue,
the_thread,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
}
@@ -561,7 +563,7 @@ void _Thread_queue_Extract( Thread_Control *the_thread )
if ( queue != NULL ) {
bool unblock;
- _Thread_Wait_remove_request( the_thread, &queue_context );
+ _Thread_Wait_remove_request( the_thread, &queue_context.Lock_context );
_Thread_queue_Context_set_MP_callout(
&queue_context,
_Thread_queue_MP_callout_do_nothing
@@ -576,7 +578,7 @@ void _Thread_queue_Extract( Thread_Control *the_thread )
unblock,
queue,
the_thread,
- &queue_context.Lock_context
+ &queue_context.Lock_context.Lock_context
);
} else {
_Thread_Wait_release( the_thread, &queue_context );
@@ -612,10 +614,10 @@ void _Thread_queue_Surrender(
unblock,
queue,
new_owner,
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
} else {
- _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+ _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
}
if ( !keep_priority ) {
diff --git a/cpukit/score/src/threadqflush.c b/cpukit/score/src/threadqflush.c
index df2859d51f..835858dd5a 100644
--- a/cpukit/score/src/threadqflush.c
+++ b/cpukit/score/src/threadqflush.c
@@ -109,9 +109,9 @@ size_t _Thread_queue_Flush_critical(
Per_CPU_Control *cpu_self;
cpu_self = _Thread_Dispatch_disable_critical(
- &queue_context->Lock_context
+ &queue_context->Lock_context.Lock_context
);
- _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+ _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
do {
Thread_Control *the_thread;
@@ -126,7 +126,7 @@ size_t _Thread_queue_Flush_critical(
_Thread_Dispatch_enable( cpu_self );
} else {
- _Thread_queue_Queue_release( queue, &queue_context->Lock_context );
+ _Thread_queue_Queue_release( queue, &queue_context->Lock_context.Lock_context );
}
return flushed;
diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
index b7804a5af8..e963c732a8 100644
--- a/cpukit/score/src/threadrestart.c
+++ b/cpukit/score/src/threadrestart.c
@@ -536,7 +536,7 @@ void _Thread_Close( Thread_Control *the_thread, Thread_Control *executing )
_Thread_queue_Context_initialize( &queue_context );
_Thread_queue_Context_set_expected_level( &queue_context, 2 );
_Thread_queue_Context_set_no_timeout( &queue_context );
- _Thread_State_acquire( the_thread, &queue_context.Lock_context );
+ _Thread_State_acquire( the_thread, &queue_context.Lock_context.Lock_context );
_Thread_Join(
the_thread,
STATES_WAITING_FOR_JOIN,