Changeset 7851555 in rtems


Ignore:
Timestamp:
Jul 3, 2017, 12:05:26 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
6b1d8c7
Parents:
6223097a
git-author:
Sebastian Huber <sebastian.huber@…> (07/03/17 12:05:26)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/07/17 05:28:29)
Message:

score: Move processor affinity to Thread_Control

Update #3059.

Files:
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/Makefile.am

    r6223097a r7851555  
    162162libscore_a_SOURCES += src/cpusetprintsupport.c
    163163libscore_a_SOURCES += src/schedulerdefaultaskforhelp.c
    164 libscore_a_SOURCES += src/schedulerdefaultgetaffinity.c
    165164libscore_a_SOURCES += src/schedulerdefaultsetaffinity.c
    166165libscore_a_SOURCES += src/schedulersmp.c
  • cpukit/score/include/rtems/score/processormask.h

    r6223097a r7851555  
    253253}
    254254
     255extern const Processor_mask _Processor_mask_The_one_and_only;
     256
    255257/** @} */
    256258
  • cpukit/score/include/rtems/score/scheduler.h

    r6223097a r7851555  
    204204
    205205#if defined(RTEMS_SMP)
    206   /** @see _Scheduler_Get_affinity() */
    207   bool ( *get_affinity )(
    208     const Scheduler_Control *,
    209     Thread_Control *,
    210     size_t,
    211     cpu_set_t *
    212   );
    213  
    214206  /** @see _Scheduler_Set_affinity() */
    215207  bool ( *set_affinity )(
     
    515507
    516508#if defined(RTEMS_SMP)
    517   /**
    518    * @brief Get affinity for the default scheduler.
    519    *
    520    * @param[in] scheduler The scheduler instance.
    521    * @param[in] thread The associated thread.
    522    * @param[in] cpusetsize The size of the cpuset.
    523    * @param[out] cpuset Affinity set containing all CPUs.
    524    *
    525    * @retval 0 Successfully got cpuset
    526    * @retval -1 The cpusetsize is invalid for the system
    527    */
    528   bool _Scheduler_default_Get_affinity(
    529     const Scheduler_Control *scheduler,
    530     Thread_Control          *thread,
    531     size_t                   cpusetsize,
    532     cpu_set_t               *cpuset
    533   );
    534 
    535509  /**
    536510   * @brief Set affinity for the default scheduler.
     
    554528
    555529  #define SCHEDULER_OPERATION_DEFAULT_GET_SET_AFFINITY \
    556     , _Scheduler_default_Get_affinity \
    557530    , _Scheduler_default_Set_affinity
    558531#else
  • cpukit/score/include/rtems/score/schedulerimpl.h

    r6223097a r7851555  
    612612#endif
    613613  }
    614 }
    615 
    616 RTEMS_INLINE_ROUTINE bool _Scheduler_default_Get_affinity_body(
    617   const Scheduler_Control *scheduler,
    618   Thread_Control          *the_thread,
    619   size_t                   cpusetsize,
    620   cpu_set_t               *cpuset
    621 )
    622 {
    623   (void) the_thread;
    624 
    625   _Scheduler_Get_processor_set( scheduler, cpusetsize, cpuset );
    626 
    627   return true;
    628614}
    629615
  • cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h

    r6223097a r7851555  
    6969    _Scheduler_default_Tick, \
    7070    _Scheduler_SMP_Start_idle, \
    71     _Scheduler_priority_affinity_SMP_Get_affinity, \
    7271    _Scheduler_priority_affinity_SMP_Set_affinity \
    7372  }
     
    101100  Thread_Control          *thread,
    102101  Scheduler_Node          *node
    103 );
    104 
    105 /**
    106  * @brief Get affinity for the priority affinity SMP scheduler.
    107  *
    108  * @param[in] scheduler The scheduler of the thread.
    109  * @param[in] thread The associated thread.
    110  * @param[in] cpusetsize The size of the cpuset.
    111  * @param[in,out] cpuset The associated affinity set.
    112  *
    113  * @retval 0 Successfully got cpuset
    114  * @retval -1 The cpusetsize is invalid for the system
    115  */
    116 bool _Scheduler_priority_affinity_SMP_Get_affinity(
    117   const Scheduler_Control *scheduler,
    118   Thread_Control          *thread,
    119   size_t                   cpusetsize,
    120   cpu_set_t               *cpuset
    121102);
    122103
  • cpukit/score/include/rtems/score/thread.h

    r6223097a r7851555  
    3838
    3939#if defined(RTEMS_SMP)
    40   #include <rtems/score/cpuset.h>
     40#include <rtems/score/processormask.h>
    4141#endif
    4242
     
    312312   */
    313313  Scheduler_Node *requests;
     314
     315  /**
     316   * @brief The thread processor affinity set.
     317   */
     318  Processor_mask Affinity;
    314319#endif
    315320
  • cpukit/score/src/processormaskcopy.c

    r6223097a r7851555  
    2626
    2727#include <rtems/score/processormask.h>
     28
     29const Processor_mask _Processor_mask_The_one_and_only = { .__bits[ 0 ] = 1 };
    2830
    2931Processor_mask_Copy_status _Processor_mask_Copy(
  • cpukit/score/src/schedulergetaffinity.c

    r6223097a r7851555  
    11/*
    2  * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    2525)
    2626{
    27   const Scheduler_Control *scheduler;
    28   ISR_lock_Context         lock_context;
    29   bool                     ok;
    30 
    31   if ( !_CPU_set_Is_large_enough( cpusetsize ) ) {
    32     return false;
    33   }
     27  const Scheduler_Control    *scheduler;
     28  ISR_lock_Context            lock_context;
     29  Processor_mask             *affinity;
     30  Processor_mask_Copy_status  status;
    3431
    3532  scheduler = _Thread_Scheduler_get_home( the_thread );
     
    3734
    3835#if defined(RTEMS_SMP)
    39   ok = ( *scheduler->Operations.get_affinity )(
    40     scheduler,
    41     the_thread,
    42     cpusetsize,
    43     cpuset
    44   );
     36  affinity = &the_thread->Scheduler.Affinity;
    4537#else
    46   ok = _Scheduler_default_Get_affinity_body(
    47     scheduler,
    48     the_thread,
    49     cpusetsize,
    50     cpuset
    51   );
     38  affinity = &_Processor_mask_The_one_and_only;
    5239#endif
     40  status = _Processor_mask_To_cpu_set_t( affinity, cpusetsize, cpuset );
    5341
    5442  _Scheduler_Release_critical( scheduler, &lock_context );
    55   return ok;
     43  return status == PROCESSOR_MASK_COPY_LOSSLESS;
    5644}
  • cpukit/score/src/schedulerpriorityaffinitysmp.c

    r6223097a r7851555  
    612612}
    613613
    614 /*
    615  * This is the public scheduler specific Change Priority operation.
    616  */
    617 bool _Scheduler_priority_affinity_SMP_Get_affinity(
    618   const Scheduler_Control *scheduler,
    619   Thread_Control          *thread,
    620   size_t                   cpusetsize,
    621   cpu_set_t               *cpuset
    622 )
    623 {
    624   Scheduler_priority_affinity_SMP_Node *node =
    625     _Scheduler_priority_affinity_SMP_Thread_get_node(thread);
    626 
    627   (void) scheduler;
    628 
    629   if ( node->Affinity.setsize != cpusetsize ) {
    630     return false;
    631   }
    632 
    633   CPU_COPY( node->Affinity.set, cpuset );
    634   return true;
    635 }
    636 
    637614bool _Scheduler_priority_affinity_SMP_Set_affinity(
    638615  const Scheduler_Control *scheduler,
  • cpukit/score/src/threadinitialize.c

    r6223097a r7851555  
    249249  the_thread->Scheduler.home = scheduler;
    250250  _ISR_lock_Initialize( &the_thread->Scheduler.Lock, "Thread Scheduler" );
     251  _Processor_mask_Assign( &the_thread->Scheduler.Affinity, &_SMP_Online_processors );
    251252  _ISR_lock_Initialize( &the_thread->Wait.Lock.Default, "Thread Wait Default" );
    252253  _Thread_queue_Gate_open( &the_thread->Wait.Lock.Tranquilizer );
  • testsuites/smptests/smpaffinity01/init.c

    r6223097a r7851555  
    8585    "Init - rtems_task_get_affinity - Invalid cpusetsize - RTEMS_INVALID_NUMBER"
    8686  );
    87   sc = rtems_task_get_affinity( Init_id,  sizeof(cpu_set_t) * 2, &cpuset );
     87  sc = rtems_task_get_affinity( Init_id,  1, &cpuset );
    8888  rtems_test_assert( sc == RTEMS_INVALID_NUMBER );
    8989
  • testsuites/smptests/smppsxaffinity02/init.c

    r6223097a r7851555  
    9090  /* Verify pthread_getaffinity_np validates cpusetsize */
    9191  puts( "Init - pthread_getaffinity_np - Invalid cpusetsize - EINVAL" );
    92   sc = pthread_getaffinity_np( Init_id,  sizeof(cpu_set_t) * 2, &cpuset );
     92  sc = pthread_getaffinity_np( Init_id,  1, &cpuset );
    9393  rtems_test_assert( sc == EINVAL );
    9494
  • testsuites/smptests/smpscheduler02/init.c

    r6223097a r7851555  
    11/*
    2  * Copyright (c) 2014, 2016 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2014, 2017 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    208208  cpu_set_t second_cpu;
    209209  cpu_set_t all_cpus;
     210  cpu_set_t online_cpus;
    210211  uint32_t cpu_count;
     212
     213  cpu_count = rtems_get_processor_count();
     214  rtems_test_assert(cpu_count == 1 || cpu_count == 2);
     215
     216  rtems_test_assert(rtems_get_current_processor() == 0);
    211217
    212218  main_task_id = rtems_task_self();
     
    222228  CPU_SET(1, &all_cpus);
    223229
    224   cpu_count = rtems_get_processor_count();
    225 
    226   rtems_test_assert(rtems_get_current_processor() == 0);
     230  CPU_ZERO(&online_cpus);
     231  CPU_SET(0, &online_cpus);
     232
     233  if (cpu_count > 1) {
     234    CPU_SET(1, &online_cpus);
     235  }
    227236
    228237  sc = rtems_scheduler_ident(SCHED_A, &scheduler_a_id);
     
    305314  sc = rtems_task_get_affinity(task_id, sizeof(cpuset), &cpuset);
    306315  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    307   rtems_test_assert(CPU_EQUAL(&cpuset, &first_cpu));
     316  rtems_test_assert(CPU_EQUAL(&cpuset, &online_cpus));
    308317
    309318  rtems_test_assert(sched_get_priority_min(SCHED_RR) == 1);
     
    327336    sc = rtems_task_get_affinity(task_id, sizeof(cpuset), &cpuset);
    328337    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    329     rtems_test_assert(CPU_EQUAL(&cpuset, &second_cpu));
     338    rtems_test_assert(CPU_EQUAL(&cpuset, &online_cpus));
    330339
    331340    sc = rtems_task_set_affinity(task_id, sizeof(all_cpus), &all_cpus);
Note: See TracChangeset for help on using the changeset viewer.