Changeset 05ca53d in rtems


Ignore:
Timestamp:
Oct 31, 2016, 12:08:33 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
58bced6
Parents:
1f5bee3
git-author:
Sebastian Huber <sebastian.huber@…> (10/31/16 12:08:33)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/10/16 08:22:09)
Message:

rtems: Add scheduler processor add/remove

Update #2797.

Files:
6 added
20 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/Makefile.am

    r1f5bee3 r05ca53d  
    106106librtems_a_SOURCES += src/taskwakeafter.c
    107107librtems_a_SOURCES += src/taskwakewhen.c
     108librtems_a_SOURCES += src/scheduleraddprocessor.c
    108109librtems_a_SOURCES += src/schedulergetprocessorset.c
    109110librtems_a_SOURCES += src/schedulerident.c
     111librtems_a_SOURCES += src/schedulerremoveprocessor.c
    110112
    111113## RATEMON_C_FILES
  • cpukit/rtems/include/rtems/rtems/tasks.h

    r1f5bee3 r05ca53d  
    466466 * @param[in] task_id Identifier of the task.  Use @ref RTEMS_SELF to select
    467467 * the executing task.
    468  * @param[out] scheduler_id Identifier of the scheduler.
     468 * @param[out] scheduler_id Identifier of the scheduler instance.
    469469 *
    470470 * @retval RTEMS_SUCCESSFUL Successful operation.
     
    564564#if defined(__RTEMS_HAVE_SYS_CPUSET_H__)
    565565/**
    566  * @brief Gets the set of processors owned by the scheduler.
    567  *
    568  * @param[in] scheduler_id Identifier of the scheduler.
     566 * @brief Gets the set of processors owned by the specified scheduler instance.
     567 *
     568 * @param[in] scheduler_id Identifier of the scheduler instance.
    569569 * @param[in] cpusetsize Size of the specified processor set buffer in
    570570 * bytes.  This value must be positive.
     
    575575 * @retval RTEMS_SUCCESSFUL Successful operation.
    576576 * @retval RTEMS_INVALID_ADDRESS The @a cpuset parameter is @c NULL.
    577  * @retval RTEMS_INVALID_ID Invalid scheduler identifier.
     577 * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier.
    578578 * @retval RTEMS_INVALID_NUMBER The processor set buffer is too small for the
    579579 * set of processors owned by the scheduler.
     
    585585);
    586586#endif
     587
     588/**
     589 * @brief Adds a processor to the set of processors owned by the specified
     590 * scheduler instance.
     591 *
     592 * Must be called from task context.  This operation obtains and releases the
     593 * objects allocator lock.
     594 *
     595 * @param[in] scheduler_id Identifier of the scheduler instance.
     596 * @param[in] cpu_index Index of the processor to add.
     597 *
     598 * @retval RTEMS_SUCCESSFUL Successful operation.
     599 * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier.
     600 * @retval RTEMS_NOT_CONFIGURED The processor is not configured to be used by
     601 *   the application.
     602 * @retval RTEMS_INCORRECT_STATE The processor is configured to be used by
     603 *   the application, however, it is not online.
     604 * @retval RTEMS_RESOURCE_IN_USE The processor is already assigned to a
     605 *   scheduler instance.
     606 */
     607rtems_status_code rtems_scheduler_add_processor(
     608  rtems_id scheduler_id,
     609  uint32_t cpu_index
     610);
     611
     612/**
     613 * @brief Removes a processor from set of processors owned by the specified
     614 * scheduler instance.
     615 *
     616 * Must be called from task context.  This operation obtains and releases the
     617 * objects allocator lock.  Removing a processor from a scheduler is a complex
     618 * operation that involves all tasks of the system.
     619 *
     620 * @param[in] scheduler_id Identifier of the scheduler instance.
     621 * @param[in] cpu_index Index of the processor to add.
     622 *
     623 * @retval RTEMS_SUCCESSFUL Successful operation.
     624 * @retval RTEMS_INVALID_ID Invalid scheduler instance identifier.
     625 * @retval RTEMS_INVALID_NUMBER The processor is not owned by the specified
     626 *   scheduler instance.
     627 * @retval RTEMS_RESOURCE_IN_USE The set of processors owned by the specified
     628 *   scheduler instance would be empty after the processor removal and there
     629 *   exists a non-idle task that uses this scheduler instance as its home
     630 *   scheduler instance.
     631 */
     632rtems_status_code rtems_scheduler_remove_processor(
     633  rtems_id scheduler_id,
     634  uint32_t cpu_index
     635);
    587636
    588637/**@}*/
  • cpukit/score/include/rtems/score/percpu.h

    r1f5bee3 r05ca53d  
    427427       */
    428428      const struct Scheduler_Context *context;
     429
     430      /**
     431       * @brief The idle thread for this processor in case it is online and
     432       * currently not used by a scheduler instance.
     433       */
     434      struct _Thread_Control *idle_if_online_and_unused;
    429435    } Scheduler;
    430436
  • cpukit/score/include/rtems/score/scheduler.h

    r1f5bee3 r05ca53d  
    148148    Scheduler_Node          *node,
    149149    Thread_Scheduler_state   next_state
     150  );
     151
     152  /**
     153   * @brief Add processor operation.
     154   *
     155   * @param[in] scheduler The scheduler instance to add the processor.
     156   * @param[in] idle The idle thread of the processor to add.
     157   */
     158  void ( *add_processor )(
     159    const Scheduler_Control *scheduler,
     160    Thread_Control          *idle
     161  );
     162
     163  /**
     164   * @brief Remove processor operation.
     165   *
     166   * @param[in] scheduler The scheduler instance to remove the processor.
     167   * @param[in] cpu The processor to remove.
     168   *
     169   * @return The idle thread of the removed processor.
     170   */
     171  Thread_Control *( *remove_processor )(
     172    const Scheduler_Control *scheduler,
     173    struct Per_CPU_Control  *cpu
    150174  );
    151175#endif
     
    393417    _Scheduler_default_Ask_for_help, \
    394418    _Scheduler_default_Reconsider_help_request, \
    395     _Scheduler_default_Withdraw_node,
     419    _Scheduler_default_Withdraw_node, \
     420    NULL, \
     421    NULL,
    396422#else
    397423  #define SCHEDULER_OPERATION_DEFAULT_ASK_FOR_HELP
  • cpukit/score/include/rtems/score/schedulerpriorityaffinitysmp.h

    r1f5bee3 r05ca53d  
    6161    _Scheduler_priority_affinity_SMP_Reconsider_help_request, \
    6262    _Scheduler_priority_affinity_SMP_Withdraw_node, \
     63    _Scheduler_priority_affinity_SMP_Add_processor, \
     64    _Scheduler_priority_affinity_SMP_Remove_processor, \
    6365    _Scheduler_priority_affinity_SMP_Node_initialize, \
    6466    _Scheduler_default_Node_destroy, \
     
    144146);
    145147
     148void _Scheduler_priority_affinity_SMP_Add_processor(
     149  const Scheduler_Control *scheduler,
     150  Thread_Control          *idle
     151);
     152
     153Thread_Control *_Scheduler_priority_affinity_SMP_Remove_processor(
     154  const Scheduler_Control *scheduler,
     155  struct Per_CPU_Control  *cpu
     156);
     157
    146158/**
    147159 * @brief Set affinity for the priority affinity SMP scheduler.
  • cpukit/score/include/rtems/score/schedulerprioritysmp.h

    r1f5bee3 r05ca53d  
    9090    _Scheduler_priority_SMP_Reconsider_help_request, \
    9191    _Scheduler_priority_SMP_Withdraw_node, \
     92    _Scheduler_priority_SMP_Add_processor, \
     93    _Scheduler_priority_SMP_Remove_processor, \
    9294    _Scheduler_priority_SMP_Node_initialize, \
    9395    _Scheduler_default_Node_destroy, \
     
    145147);
    146148
     149void _Scheduler_priority_SMP_Add_processor(
     150  const Scheduler_Control *scheduler,
     151  Thread_Control          *idle
     152);
     153
     154Thread_Control *_Scheduler_priority_SMP_Remove_processor(
     155  const Scheduler_Control *scheduler,
     156  struct Per_CPU_Control  *cpu
     157);
     158
    147159bool _Scheduler_priority_SMP_Yield(
    148160  const Scheduler_Control *scheduler,
  • cpukit/score/include/rtems/score/schedulerprioritysmpimpl.h

    r1f5bee3 r05ca53d  
    5656{
    5757  return (Scheduler_priority_SMP_Node *) node;
     58}
     59
     60static inline bool _Scheduler_priority_SMP_Has_ready( Scheduler_Context *context )
     61{
     62  Scheduler_priority_SMP_Context *self =
     63    _Scheduler_priority_SMP_Get_self( context );
     64
     65  return !_Priority_bit_map_Is_empty( &self->Bit_map );
    5866}
    5967
  • cpukit/score/include/rtems/score/schedulersimplesmp.h

    r1f5bee3 r05ca53d  
    7373    _Scheduler_simple_SMP_Reconsider_help_request, \
    7474    _Scheduler_simple_SMP_Withdraw_node, \
     75    _Scheduler_simple_SMP_Add_processor, \
     76    _Scheduler_simple_SMP_Remove_processor, \
    7577    _Scheduler_simple_SMP_Node_initialize, \
    7678    _Scheduler_default_Node_destroy, \
     
    128130);
    129131
     132void _Scheduler_simple_SMP_Add_processor(
     133  const Scheduler_Control *scheduler,
     134  Thread_Control          *idle
     135);
     136
     137Thread_Control *_Scheduler_simple_SMP_Remove_processor(
     138  const Scheduler_Control *scheduler,
     139  struct Per_CPU_Control  *cpu
     140);
     141
    130142bool _Scheduler_simple_SMP_Yield(
    131143  const Scheduler_Control *scheduler,
  • cpukit/score/include/rtems/score/schedulersmpimpl.h

    r1f5bee3 r05ca53d  
    276276 */
    277277
     278typedef bool ( *Scheduler_SMP_Has_ready )(
     279  Scheduler_Context *context
     280);
     281
    278282typedef Scheduler_Node *( *Scheduler_SMP_Get_highest_ready )(
    279283  Scheduler_Context *context,
     
    468472
    469473  _Chain_Prepend_unprotected( &self->Idle_threads, &idle->Object.Node );
     474}
     475
     476static inline void _Scheduler_SMP_Exctract_idle_thread(
     477  Thread_Control *idle
     478)
     479{
     480  _Chain_Extract_unprotected( &idle->Object.Node );
    470481}
    471482
     
    12721283}
    12731284
     1285static inline void _Scheduler_SMP_Add_processor(
     1286  Scheduler_Context       *context,
     1287  Thread_Control          *idle,
     1288  Scheduler_SMP_Has_ready  has_ready,
     1289  Scheduler_SMP_Enqueue    enqueue_scheduled_fifo
     1290)
     1291{
     1292  Scheduler_SMP_Context *self;
     1293  Scheduler_Node        *node;
     1294
     1295  self = _Scheduler_SMP_Get_self( context );
     1296  idle->Scheduler.state = THREAD_SCHEDULER_SCHEDULED;
     1297  _Scheduler_SMP_Release_idle_thread( &self->Base, idle );
     1298  node = _Thread_Scheduler_get_home_node( idle );
     1299  _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_SCHEDULED );
     1300
     1301  if ( ( *has_ready )( &self->Base ) ) {
     1302    ( *enqueue_scheduled_fifo )( &self->Base, node );
     1303  } else {
     1304    _Chain_Append_unprotected( &self->Scheduled, &node->Node );
     1305  }
     1306}
     1307
     1308static inline Thread_Control *_Scheduler_SMP_Remove_processor(
     1309  Scheduler_Context     *context,
     1310  Per_CPU_Control       *cpu,
     1311  Scheduler_SMP_Extract  extract_from_ready,
     1312  Scheduler_SMP_Enqueue  enqueue_fifo
     1313)
     1314{
     1315  Scheduler_SMP_Context *self;
     1316  Chain_Node            *chain_node;
     1317  Scheduler_Node        *victim_node;
     1318  Thread_Control        *victim_user;
     1319  Thread_Control        *victim_owner;
     1320  Thread_Control        *idle;
     1321
     1322  self = _Scheduler_SMP_Get_self( context );
     1323  chain_node = _Chain_First( &self->Scheduled );
     1324
     1325  do {
     1326    _Assert( chain_node != _Chain_Immutable_tail( &self->Scheduled ) );
     1327    victim_node = (Scheduler_Node *) chain_node;
     1328    victim_user = _Scheduler_Node_get_user( victim_node );
     1329    chain_node = _Chain_Next( chain_node );
     1330  } while ( _Thread_Get_CPU( victim_user ) != cpu );
     1331
     1332  _Scheduler_SMP_Extract_from_scheduled( victim_node );
     1333  victim_owner = _Scheduler_Node_get_owner( victim_node );
     1334
     1335  if ( !victim_owner->is_idle ) {
     1336    Scheduler_Node *idle_node;
     1337
     1338    _Scheduler_Release_idle_thread(
     1339      &self->Base,
     1340      victim_node,
     1341      _Scheduler_SMP_Release_idle_thread
     1342    );
     1343    idle = _Scheduler_SMP_Get_idle_thread( &self->Base );
     1344    idle_node = _Thread_Scheduler_get_home_node( idle );
     1345    ( *extract_from_ready )( &self->Base, idle_node );
     1346    _Scheduler_SMP_Preempt(
     1347      &self->Base,
     1348      idle_node,
     1349      victim_node,
     1350      _Scheduler_SMP_Allocate_processor_exact
     1351    );
     1352
     1353    if ( !_Chain_Is_empty( &self->Scheduled ) ) {
     1354      ( *enqueue_fifo )( context, victim_node );
     1355    }
     1356  } else {
     1357    _Assert( victim_owner == victim_user );
     1358    _Assert( _Scheduler_Node_get_idle( victim_node ) == NULL );
     1359    idle = victim_owner;
     1360    _Scheduler_SMP_Exctract_idle_thread( idle );
     1361  }
     1362
     1363  return idle;
     1364}
     1365
    12741366/** @} */
    12751367
  • cpukit/score/include/rtems/score/schedulerstrongapa.h

    r1f5bee3 r05ca53d  
    9090    _Scheduler_strong_APA_Reconsider_help_request, \
    9191    _Scheduler_strong_APA_Withdraw_node, \
     92    _Scheduler_strong_APA_Add_processor, \
     93    _Scheduler_strong_APA_Remove_processor, \
    9294    _Scheduler_strong_APA_Node_initialize, \
    9395    _Scheduler_default_Node_destroy, \
     
    145147);
    146148
     149void _Scheduler_strong_APA_Add_processor(
     150  const Scheduler_Control *scheduler,
     151  Thread_Control          *idle
     152);
     153
     154Thread_Control *_Scheduler_strong_APA_Remove_processor(
     155  const Scheduler_Control *scheduler,
     156  struct Per_CPU_Control  *cpu
     157);
     158
    147159bool _Scheduler_strong_APA_Yield(
    148160  const Scheduler_Control *scheduler,
  • cpukit/score/src/schedulerpriorityaffinitysmp.c

    r1f5bee3 r05ca53d  
    579579}
    580580
     581void _Scheduler_priority_affinity_SMP_Add_processor(
     582  const Scheduler_Control *scheduler,
     583  Thread_Control          *idle
     584)
     585{
     586  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     587
     588  _Scheduler_SMP_Add_processor(
     589    context,
     590    idle,
     591    _Scheduler_priority_SMP_Has_ready,
     592    _Scheduler_priority_affinity_SMP_Enqueue_scheduled_fifo
     593  );
     594}
     595
     596Thread_Control *_Scheduler_priority_affinity_SMP_Remove_processor(
     597  const Scheduler_Control *scheduler,
     598  Per_CPU_Control         *cpu
     599)
     600{
     601  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     602
     603  return _Scheduler_SMP_Remove_processor(
     604    context,
     605    cpu,
     606    _Scheduler_priority_SMP_Extract_from_ready,
     607    _Scheduler_priority_affinity_SMP_Enqueue_fifo
     608  );
     609}
     610
    581611/*
    582612 * This is the public scheduler specific Change Priority operation.
  • cpukit/score/src/schedulerprioritysmp.c

    r1f5bee3 r05ca53d  
    313313}
    314314
     315void _Scheduler_priority_SMP_Add_processor(
     316  const Scheduler_Control *scheduler,
     317  Thread_Control          *idle
     318)
     319{
     320  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     321
     322  _Scheduler_SMP_Add_processor(
     323    context,
     324    idle,
     325    _Scheduler_priority_SMP_Has_ready,
     326    _Scheduler_priority_SMP_Enqueue_scheduled_fifo
     327  );
     328}
     329
     330Thread_Control *_Scheduler_priority_SMP_Remove_processor(
     331  const Scheduler_Control *scheduler,
     332  Per_CPU_Control         *cpu
     333)
     334{
     335  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     336
     337  return _Scheduler_SMP_Remove_processor(
     338    context,
     339    cpu,
     340    _Scheduler_priority_SMP_Extract_from_ready,
     341    _Scheduler_priority_SMP_Enqueue_fifo
     342  );
     343}
     344
    315345bool _Scheduler_priority_SMP_Yield(
    316346  const Scheduler_Control *scheduler,
  • cpukit/score/src/schedulersimplesmp.c

    r1f5bee3 r05ca53d  
    7070}
    7171
     72static bool _Scheduler_simple_SMP_Has_ready( Scheduler_Context *context )
     73{
     74  Scheduler_simple_SMP_Context *self =
     75    _Scheduler_simple_SMP_Get_self( context );
     76
     77  return !_Chain_Is_empty( &self->Ready );
     78}
     79
    7280static Scheduler_Node *_Scheduler_simple_SMP_Get_highest_ready(
    7381  Scheduler_Context *context,
     
    380388}
    381389
     390void _Scheduler_simple_SMP_Add_processor(
     391  const Scheduler_Control *scheduler,
     392  Thread_Control          *idle
     393)
     394{
     395  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     396
     397  _Scheduler_SMP_Add_processor(
     398    context,
     399    idle,
     400    _Scheduler_simple_SMP_Has_ready,
     401    _Scheduler_simple_SMP_Enqueue_scheduled_fifo
     402  );
     403}
     404
     405Thread_Control *_Scheduler_simple_SMP_Remove_processor(
     406  const Scheduler_Control *scheduler,
     407  Per_CPU_Control         *cpu
     408)
     409{
     410  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     411
     412  return _Scheduler_SMP_Remove_processor(
     413    context,
     414    cpu,
     415    _Scheduler_simple_SMP_Extract_from_ready,
     416    _Scheduler_simple_SMP_Enqueue_fifo
     417  );
     418}
     419
    382420bool _Scheduler_simple_SMP_Yield(
    383421  const Scheduler_Control *scheduler,
  • cpukit/score/src/schedulersmpstartidle.c

    r1f5bee3 r05ca53d  
    2727  node = _Scheduler_SMP_Thread_get_node( idle );
    2828
    29   _Scheduler_Thread_change_state( thread, THREAD_SCHEDULER_SCHEDULED );
     29  _Scheduler_Thread_change_state( idle, THREAD_SCHEDULER_SCHEDULED );
    3030  node->state = SCHEDULER_SMP_NODE_SCHEDULED;
    3131
  • cpukit/score/src/schedulerstrongapa.c

    r1f5bee3 r05ca53d  
    201201}
    202202
     203static bool _Scheduler_strong_APA_Has_ready( Scheduler_Context *context )
     204{
     205  Scheduler_strong_APA_Context *self =
     206    _Scheduler_strong_APA_Get_self( context );
     207
     208  return !_Priority_bit_map_Is_empty( &self->Bit_map );
     209}
     210
    203211static Scheduler_Node *_Scheduler_strong_APA_Get_highest_ready(
    204212  Scheduler_Context *context,
     
    439447}
    440448
     449void _Scheduler_strong_APA_Add_processor(
     450  const Scheduler_Control *scheduler,
     451  Thread_Control          *idle
     452)
     453{
     454  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     455
     456  _Scheduler_SMP_Add_processor(
     457    context,
     458    idle,
     459    _Scheduler_strong_APA_Has_ready,
     460    _Scheduler_strong_APA_Enqueue_scheduled_fifo
     461  );
     462}
     463
     464Thread_Control *_Scheduler_strong_APA_Remove_processor(
     465  const Scheduler_Control *scheduler,
     466  Per_CPU_Control         *cpu
     467)
     468{
     469  Scheduler_Context *context = _Scheduler_Get_context( scheduler );
     470
     471  return _Scheduler_SMP_Remove_processor(
     472    context,
     473    cpu,
     474    _Scheduler_strong_APA_Extract_from_ready,
     475    _Scheduler_strong_APA_Enqueue_fifo
     476  );
     477}
     478
    441479bool _Scheduler_strong_APA_Yield(
    442480  const Scheduler_Control *scheduler,
  • cpukit/score/src/threadinitialize.c

    r1f5bee3 r05ca53d  
    191191      scheduler_node = scheduler_node_for_index;
    192192    } else {
    193       priority_for_index = 0;
     193      /*
     194       * Use the idle thread priority for the non-home scheduler instances by
     195       * default.
     196       */
     197      priority_for_index = _Scheduler_Map_priority(
     198        scheduler_for_index,
     199        scheduler_for_index->maximum_priority
     200      );
    194201    }
    195202
  • testsuites/smptests/Makefile.am

    r1f5bee3 r05ca53d  
    3838SUBDIRS += smpscheduler02
    3939SUBDIRS += smpscheduler03
     40SUBDIRS += smpscheduler04
    4041SUBDIRS += smpschedsem01
    4142SUBDIRS += smpsignal01
  • testsuites/smptests/configure.ac

    r1f5bee3 r05ca53d  
    9898smpscheduler02/Makefile
    9999smpscheduler03/Makefile
     100smpscheduler04/Makefile
    100101smpschedsem01/Makefile
    101102smpsignal01/Makefile
  • testsuites/smptests/smpscheduler02/init.c

    r1f5bee3 r05ca53d  
    3838static rtems_id imtx_id;
    3939
     40static volatile bool ready;
     41
    4042static void task(rtems_task_argument arg)
    4143{
     
    6567  while (1) {
    6668    /* Do nothing */
     69  }
     70}
     71
     72static void sticky_task(rtems_task_argument arg)
     73{
     74  rtems_status_code sc;
     75  rtems_id mtx_id;
     76
     77  (void) arg;
     78
     79  rtems_test_assert(rtems_get_current_processor() == 0);
     80
     81  sc = rtems_semaphore_create(
     82    rtems_build_name(' ', 'M', 'T', 'X'),
     83    1,
     84    RTEMS_BINARY_SEMAPHORE | RTEMS_MULTIPROCESSOR_RESOURCE_SHARING,
     85    2,
     86    &mtx_id
     87  );
     88  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     89
     90  sc = rtems_semaphore_obtain(mtx_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     91  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     92
     93  ready = true;
     94
     95  sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     96  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     97
     98  sc = rtems_semaphore_release(mtx_id);
     99  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     100
     101  sc = rtems_semaphore_delete(mtx_id);
     102  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     103
     104  sc = rtems_event_transient_send(main_task_id);
     105  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     106
     107  while (1) {
     108    /* Do nothing */
     109  }
     110}
     111
     112static void test_scheduler_add_remove_processors(void)
     113{
     114  rtems_status_code sc;
     115  rtems_id scheduler_a_id;
     116  rtems_id scheduler_c_id;
     117
     118  sc = rtems_scheduler_ident(SCHED_A, &scheduler_a_id);
     119  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     120
     121  sc = rtems_scheduler_ident(SCHED_C, &scheduler_c_id);
     122  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     123
     124  sc = rtems_scheduler_add_processor(scheduler_c_id, 62);
     125  rtems_test_assert(sc == RTEMS_NOT_CONFIGURED);
     126
     127  sc = rtems_scheduler_add_processor(scheduler_c_id, 63);
     128  rtems_test_assert(sc == RTEMS_INCORRECT_STATE);
     129
     130  sc = rtems_scheduler_remove_processor(scheduler_c_id, 62);
     131  rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
     132
     133  sc = rtems_scheduler_remove_processor(scheduler_a_id, 0);
     134  rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE);
     135
     136  if (rtems_get_processor_count() > 1) {
     137    rtems_id scheduler_b_id;
     138    rtems_id task_id;
     139
     140    sc = rtems_scheduler_ident(SCHED_B, &scheduler_b_id);
     141    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     142
     143    sc = rtems_scheduler_remove_processor(scheduler_b_id, 1);
     144    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     145
     146    sc = rtems_scheduler_add_processor(scheduler_a_id, 1);
     147    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     148
     149    rtems_test_assert(rtems_get_current_processor() == 0);
     150
     151    sc = rtems_scheduler_remove_processor(scheduler_a_id, 0);
     152    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     153
     154    rtems_test_assert(rtems_get_current_processor() == 1);
     155
     156    sc = rtems_scheduler_add_processor(scheduler_a_id, 0);
     157    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     158
     159    rtems_test_assert(rtems_get_current_processor() == 1);
     160
     161    sc = rtems_task_create(
     162      rtems_build_name('T', 'A', 'S', 'K'),
     163      2,
     164      RTEMS_MINIMUM_STACK_SIZE,
     165      RTEMS_DEFAULT_MODES,
     166      RTEMS_DEFAULT_ATTRIBUTES,
     167      &task_id
     168    );
     169    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     170
     171    sc = rtems_task_start(task_id, sticky_task, 0);
     172    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     173
     174    while (!ready) {
     175      /* Wait */
     176    }
     177
     178    sc = rtems_scheduler_remove_processor(scheduler_a_id, 1);
     179    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     180
     181    rtems_test_assert(rtems_get_current_processor() == 0);
     182
     183    sc = rtems_event_transient_send(task_id);
     184    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     185
     186    sc = rtems_event_transient_receive(RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     187    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     188
     189    sc = rtems_task_delete(task_id);
     190    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     191
     192    sc = rtems_scheduler_add_processor(scheduler_b_id, 1);
     193    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    67194  }
    68195}
     
    249376  sc = rtems_semaphore_delete(imtx_id);
    250377  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     378
     379  test_scheduler_add_remove_processors();
    251380}
    252381
     
    272401#define CONFIGURE_MAXIMUM_TASKS 2
    273402#define CONFIGURE_MAXIMUM_SEMAPHORES 2
     403#define CONFIGURE_MAXIMUM_MRSP_SEMAPHORES 1
    274404
    275405#define CONFIGURE_SMP_APPLICATION
  • testsuites/sptests/spscheduler01/init.c

    r1f5bee3 r05ca53d  
    412412}
    413413
     414static void test_scheduler_add_remove_processors(void)
     415{
     416  rtems_status_code sc;
     417  rtems_id scheduler_id;
     418
     419  sc = rtems_scheduler_ident(BLUE, &scheduler_id);
     420  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     421
     422  sc = rtems_scheduler_add_processor(invalid_id, 0);
     423  rtems_test_assert(sc == RTEMS_INVALID_ID);
     424
     425  sc = rtems_scheduler_remove_processor(invalid_id, 0);
     426  rtems_test_assert(sc == RTEMS_INVALID_ID);
     427
     428  sc = rtems_scheduler_add_processor(scheduler_id, 1);
     429  rtems_test_assert(sc == RTEMS_NOT_CONFIGURED);
     430
     431  sc = rtems_scheduler_remove_processor(scheduler_id, 1);
     432  rtems_test_assert(sc == RTEMS_INVALID_NUMBER);
     433
     434  sc = rtems_scheduler_add_processor(scheduler_id, 0);
     435  rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE);
     436
     437  sc = rtems_scheduler_remove_processor(scheduler_id, 0);
     438  rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE);
     439}
     440
    414441static void test_task_get_priority(void)
    415442{
     
    464491  test_scheduler_ident();
    465492  test_scheduler_get_processors();
     493  test_scheduler_add_remove_processors();
    466494  test_task_get_priority();
    467495
Note: See TracChangeset for help on using the changeset viewer.