From 620b23ece54a0bb43189bb9c0f14adf447cbafe6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 24 Nov 2016 06:13:11 +0100 Subject: score: Optimize _Thread_queue_Enqueue() Move thread state for _Thread_queue_Enqueue() to the thread queue context. This reduces the parameter count of _Thread_queue_Enqueue() from five to four (ARM for example has only four function parameter registers). Since the thread state is used after several function calls inside _Thread_queue_Enqueue() this parameter was saved on the stack previously. --- cpukit/posix/src/condwaitsupp.c | 5 ++++- cpukit/posix/src/nanosleep.c | 5 ++++- cpukit/posix/src/sigtimedwait.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'cpukit/posix/src') diff --git a/cpukit/posix/src/condwaitsupp.c b/cpukit/posix/src/condwaitsupp.c index 9024dbf236..589b5e2810 100644 --- a/cpukit/posix/src/condwaitsupp.c +++ b/cpukit/posix/src/condwaitsupp.c @@ -117,6 +117,10 @@ int _POSIX_Condition_variables_Wait_support( executing = _Thread_Executing; if ( !already_timedout ) { + _Thread_queue_Context_set_thread_state( + &queue_context, + STATES_WAITING_FOR_CONDITION_VARIABLE + ); _Thread_queue_Context_set_enqueue_callout( &queue_context, _POSIX_Condition_variables_Enqueue_callout @@ -125,7 +129,6 @@ int _POSIX_Condition_variables_Wait_support( &the_cond->Wait_queue.Queue, POSIX_CONDITION_VARIABLES_TQ_OPERATIONS, executing, - STATES_WAITING_FOR_CONDITION_VARIABLE, &queue_context ); error = _POSIX_Get_error_after_wait( executing ); diff --git a/cpukit/posix/src/nanosleep.c b/cpukit/posix/src/nanosleep.c index 5deb2b8c02..10158ff44b 100644 --- a/cpukit/posix/src/nanosleep.c +++ b/cpukit/posix/src/nanosleep.c @@ -47,6 +47,10 @@ static inline int nanosleep_helper( err = 0; _Thread_queue_Context_initialize( &queue_context ); + _Thread_queue_Context_set_thread_state( + &queue_context, + STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL + ); _Thread_queue_Context_set_enqueue_callout( &queue_context, _Thread_queue_Enqueue_do_nothing @@ -66,7 +70,6 @@ static inline int nanosleep_helper( &_Nanosleep_Pseudo_queue.Queue, &_Thread_queue_Operations_FIFO, _Thread_Executing, - STATES_DELAYING | STATES_INTERRUPTIBLE_BY_SIGNAL, &queue_context ); diff --git a/cpukit/posix/src/sigtimedwait.c b/cpukit/posix/src/sigtimedwait.c index 200d75fdf9..f96c32ef45 100644 --- a/cpukit/posix/src/sigtimedwait.c +++ b/cpukit/posix/src/sigtimedwait.c @@ -156,12 +156,15 @@ int sigtimedwait( executing->Wait.option = *set; executing->Wait.return_argument = the_info; + _Thread_queue_Context_set_thread_state( + &queue_context, + STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL + ); _Thread_queue_Context_set_do_nothing_enqueue_callout( &queue_context ); _Thread_queue_Enqueue( &_POSIX_signals_Wait_queue.Queue, POSIX_SIGNALS_TQ_OPERATIONS, executing, - STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL, &queue_context ); -- cgit v1.2.3