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/score/src/smpmulticastaction.c | 37 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'cpukit/score') 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