Changeset 25f5730f in rtems


Ignore:
Timestamp:
May 28, 2014, 4:11:51 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
606ed52
Parents:
a92c488
git-author:
Sebastian Huber <sebastian.huber@…> (05/28/14 16:11:51)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/02/14 06:28:42)
Message:

score: _Scheduler_Set_affinity()

Do not change the scheduler with this function. Documentation. Coding
style.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/include/rtems/rtems/tasks.h

    ra92c488 r25f5730f  
    522522 * @brief Sets the processor affinity set of a task.
    523523 *
     524 * This function will not change the scheduler of the task.  The intersection
     525 * of the processor affinity set and the set of processors owned by the
     526 * scheduler of the task must be non-empty.  It is not an error if the
     527 * processor affinity set contains processors that are not part of the set of
     528 * processors owned by the scheduler instance of the task.  A task will simply
     529 * not run under normal circumstances on these processors since the scheduler
     530 * ignores them.  Some locking protocols may temporarily use processors that
     531 * are not included in the processor affinity set of the task.  It is also not
     532 * an error if the processor affinity set contains processors that are not part
     533 * of the system.
     534 *
    524535 * @param[in] id Identifier of the task.  Use @ref RTEMS_SELF to select the
    525536 * executing task.
  • cpukit/score/include/rtems/score/schedulerimpl.h

    ra92c488 r25f5730f  
    419419)
    420420{
    421   size_t   cpu_max   = _CPU_set_Maximum_CPU_count( cpusetsize );
    422421  uint32_t cpu_count = _SMP_Get_processor_count();
    423422  uint32_t cpu_index;
     
    430429
    431430    ok = ok
    432       && ( ( CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
    433           && scheduler == scheduler_of_cpu )
     431      && ( CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
    434432        || ( !CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset )
    435433          && scheduler != scheduler_of_cpu ) );
     
    440438#endif
    441439  }
    442 
    443   for ( ; cpu_index < cpu_max ; ++cpu_index ) {
    444     ok = ok && !CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset );
    445   }
    446 
    447   _Scheduler_Set( scheduler, the_thread );
    448440
    449441  return ok;
  • cpukit/score/src/schedulersetaffinity.c

    ra92c488 r25f5730f  
    2727)
    2828{
    29   bool ok;
     29  const Scheduler_Control *scheduler = _Scheduler_Get( the_thread );
    3030
    31   if ( _CPU_set_Is_large_enough( cpusetsize ) ) {
    32 #if defined(RTEMS_SMP)
    33     uint32_t cpu_count = _SMP_Get_processor_count();
    34     uint32_t cpu_index;
    35 
    36     ok = false;
    37 
    38     for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
    39       if ( CPU_ISSET_S( (int) cpu_index, cpusetsize, cpuset ) ) {
    40         const Scheduler_Control *scheduler_of_cpu =
    41           _Scheduler_Get_by_CPU_index( cpu_index );
    42 
    43         if ( scheduler_of_cpu != NULL ) {
    44           ok = ( *scheduler_of_cpu->Operations.set_affinity )(
    45             scheduler_of_cpu,
    46             the_thread,
    47             cpusetsize,
    48             cpuset
    49           );
    50         }
    51 
    52         break;
    53       }
    54     }
    55 #else
    56     ok = _Scheduler_default_Set_affinity_body(
    57       _Scheduler_Get( the_thread ),
    58       the_thread,
    59       cpusetsize,
    60       cpuset
    61     );
    62 #endif
    63   } else {
    64     ok = false;
     31  if ( !_CPU_set_Is_large_enough( cpusetsize ) ) {
     32    return false;
    6533  }
    6634
    67   return ok;
     35#if defined(RTEMS_SMP)
     36  return ( *scheduler->Operations.set_affinity )(
     37    scheduler,
     38    the_thread,
     39    cpusetsize,
     40    cpuset
     41  );
     42#else
     43  return _Scheduler_default_Set_affinity_body(
     44    scheduler,
     45    the_thread,
     46    cpusetsize,
     47    cpuset
     48  );
     49#endif
    6850}
    6951
  • doc/user/smp.t

    ra92c488 r25f5730f  
    623623@subheading NOTES:
    624624
    625 None.
     625This function will not change the scheduler of the task.  The intersection of
     626the processor affinity set and the set of processors owned by the scheduler of
     627the task must be non-empty.  It is not an error if the processor affinity set
     628contains processors that are not part of the set of processors owned by the
     629scheduler instance of the task.  A task will simply not run under normal
     630circumstances on these processors since the scheduler ignores them.  Some
     631locking protocols may temporarily use processors that are not included in the
     632processor affinity set of the task.  It is also not an error if the processor
     633affinity set contains processors that are not part of the system.
  • testsuites/smptests/smpscheduler02/init.c

    ra92c488 r25f5730f  
    140140
    141141  sc = rtems_task_set_affinity(task_id, sizeof(all_cpus), &all_cpus);
     142  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     143
     144  sc = rtems_task_set_affinity(task_id, sizeof(first_cpu), &first_cpu);
    142145  rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
    143146
    144   sc = rtems_task_set_affinity(task_id, sizeof(first_cpu), &first_cpu);
    145   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    146 
    147   sc = rtems_task_get_scheduler(task_id, &scheduler_id);
    148   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    149   rtems_test_assert(scheduler_id == scheduler_a_id);
     147  sc = rtems_task_get_scheduler(task_id, &scheduler_id);
     148  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     149  rtems_test_assert(scheduler_id == scheduler_b_id);
    150150
    151151  sc = rtems_task_set_affinity(task_id, sizeof(second_cpu), &second_cpu);
Note: See TracChangeset for help on using the changeset viewer.