From 85d6e845d2b9c47779cc96438e3aa6e894b4a71a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 19 Apr 2019 11:01:31 +0200 Subject: score: Add _Per_CPU_Add_job() --- cpukit/include/rtems/score/percpu.h | 15 +++++++++++++- cpukit/score/src/smpmulticastaction.c | 37 ++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 17 deletions(-) (limited to 'cpukit') diff --git a/cpukit/include/rtems/score/percpu.h b/cpukit/include/rtems/score/percpu.h index eff71c4ec1..85e10fbbaa 100644 --- a/cpukit/include/rtems/score/percpu.h +++ b/cpukit/include/rtems/score/percpu.h @@ -792,12 +792,25 @@ bool _Per_CPU_State_wait_for_non_initial_state( ); /** - * @brief Performs the jobs of the specified processor. + * @brief Performs the jobs of the specified processor in FIFO order. * * @param[in, out] cpu The jobs of this processor will be performed. */ void _Per_CPU_Perform_jobs( Per_CPU_Control *cpu ); +/** + * @brief Adds the job to the tail of the processing list of the specified + * processor. + * + * This function does not send the SMP_MESSAGE_PERFORM_JOBS message the + * specified processor. + * + * @param[in, out] cpu The processor to add the job. + * @param[in, out] job The job. The Per_CPU_Job::context member must be + * initialized by the caller. + */ +void _Per_CPU_Add_job( Per_CPU_Control *cpu, Per_CPU_Job *job ); + #endif /* defined( RTEMS_SMP ) */ /* diff --git a/cpukit/score/src/smpmulticastaction.c b/cpukit/score/src/smpmulticastaction.c index ad3b1531ec..1207000e6a 100644 --- a/cpukit/score/src/smpmulticastaction.c +++ b/cpukit/score/src/smpmulticastaction.c @@ -57,6 +57,24 @@ void _Per_CPU_Perform_jobs( Per_CPU_Control *cpu ) _Per_CPU_Jobs_ISR_disable_and_acquire( cpu, &lock_context ); } +} + +void _Per_CPU_Add_job( Per_CPU_Control *cpu, Per_CPU_Job *job ) +{ + ISR_lock_Context lock_context; + + _Atomic_Store_ulong( &job->done, 0, ATOMIC_ORDER_RELAXED ); + _Assert( job->next == NULL ); + + _Per_CPU_Jobs_ISR_disable_and_acquire( cpu, &lock_context ); + + if ( cpu->Jobs.head == NULL ) { + cpu->Jobs.head = job; + } else { + *cpu->Jobs.tail = job; + } + + cpu->Jobs.tail = &job->next; _Per_CPU_Jobs_release_and_ISR_enable( cpu, &lock_context ); } @@ -97,27 +115,14 @@ static void _SMP_Issue_action_jobs( for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) { if ( _Processor_mask_Is_set( targets, cpu_index ) ) { - ISR_lock_Context lock_context; - Per_CPU_Job *job; - Per_CPU_Control *cpu; + Per_CPU_Job *job; + Per_CPU_Control *cpu; job = &jobs->Jobs[ cpu_index ]; - _Atomic_Store_ulong( &job->done, 0, ATOMIC_ORDER_RELAXED ); - _Assert( job->next == NULL ); job->context = &jobs->Context; - cpu = _Per_CPU_Get_by_index( cpu_index ); - _Per_CPU_Jobs_ISR_disable_and_acquire( cpu, &lock_context ); - - if ( cpu->Jobs.head == NULL ) { - cpu->Jobs.head = job; - } else { - *cpu->Jobs.tail = job; - } - - cpu->Jobs.tail = &job->next; - _Per_CPU_Jobs_release_and_ISR_enable( cpu, &lock_context ); + _Per_CPU_Add_job( cpu, job ); _SMP_Send_message( cpu_index, SMP_MESSAGE_PERFORM_JOBS ); } } -- cgit v1.2.3