Changeset 41cddcc in rtems


Ignore:
Timestamp:
May 20, 2019, 7:06:48 AM (6 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
5fa893e
Parents:
9b8e85e2
Message:

score: Add _Per_CPU_Wait_for_job()

Location:
cpukit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/score/percpu.h

    r9b8e85e2 r41cddcc  
    812812void _Per_CPU_Add_job( Per_CPU_Control *cpu, Per_CPU_Job *job );
    813813
     814/**
     815 * @brief Waits for the job carried out by the specified processor.
     816 *
     817 * This function may result in an SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS
     818 * fatal error.
     819 *
     820 * @param[in] cpu The processor carrying out the job.
     821 * @param[in] job The job to wait for.
     822 */
     823void _Per_CPU_Wait_for_job(
     824  const Per_CPU_Control *cpu,
     825  const Per_CPU_Job     *job
     826);
     827
    814828#endif /* defined( RTEMS_SMP ) */
    815829
  • cpukit/score/src/smpmulticastaction.c

    r9b8e85e2 r41cddcc  
    103103}
    104104
     105void _Per_CPU_Wait_for_job(
     106  const Per_CPU_Control *cpu,
     107  const Per_CPU_Job     *job
     108)
     109{
     110  while (
     111    _Atomic_Load_ulong( &job->done, ATOMIC_ORDER_ACQUIRE )
     112      != PER_CPU_JOB_DONE
     113  ) {
     114    switch ( cpu->state ) {
     115      case PER_CPU_STATE_INITIAL:
     116      case PER_CPU_STATE_READY_TO_START_MULTITASKING:
     117      case PER_CPU_STATE_REQUEST_START_MULTITASKING:
     118        _CPU_SMP_Processor_event_broadcast();
     119        /* Fall through */
     120      case PER_CPU_STATE_UP:
     121        /*
     122         * Calling this function with the current processor is intentional.
     123         * We have to perform our own jobs here in case inter-processor
     124         * interrupts are not working.
     125         */
     126        _Per_CPU_Try_perform_jobs( _Per_CPU_Get() );
     127        break;
     128      default:
     129        _SMP_Fatal( SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS );
     130        break;
     131    }
     132  }
     133}
     134
    105135typedef struct {
    106136  Per_CPU_Job_context Context;
     
    141171  for ( cpu_index = 0; cpu_index < cpu_max; ++cpu_index ) {
    142172    if ( _Processor_mask_Is_set( targets, cpu_index ) ) {
    143       const Per_CPU_Job *job;
    144       Per_CPU_Control   *cpu;
    145 
     173      const Per_CPU_Control *cpu;
     174      const Per_CPU_Job     *job;
     175
     176      cpu = _Per_CPU_Get_by_index( cpu_index );
    146177      job = &jobs->Jobs[ cpu_index ];
    147       cpu = _Per_CPU_Get_by_index( cpu_index );
    148 
    149       while (
    150         _Atomic_Load_ulong( &job->done, ATOMIC_ORDER_ACQUIRE )
    151           != PER_CPU_JOB_DONE
    152       ) {
    153         switch ( cpu->state ) {
    154           case PER_CPU_STATE_INITIAL:
    155           case PER_CPU_STATE_READY_TO_START_MULTITASKING:
    156           case PER_CPU_STATE_REQUEST_START_MULTITASKING:
    157             _CPU_SMP_Processor_event_broadcast();
    158             /* Fall through */
    159           case PER_CPU_STATE_UP:
    160             /*
    161              * Calling this function with the current processor is intentional.
    162              * We have to perform our own jobs here in case inter-processor
    163              * interrupts are not working.
    164              */
    165             _Per_CPU_Try_perform_jobs( _Per_CPU_Get() );
    166             break;
    167           default:
    168             _SMP_Fatal( SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS );
    169             break;
    170         }
    171       }
     178      _Per_CPU_Wait_for_job( cpu, job );
    172179    }
    173180  }
Note: See TracChangeset for help on using the changeset viewer.