Changeset c0bd006 in rtems


Ignore:
Timestamp:
Jun 30, 2016, 12:08:18 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
4cb13c39
Parents:
8d5b0380
git-author:
Sebastian Huber <sebastian.huber@…> (06/30/16 12:08:18)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/01/16 09:51:49)
Message:

rtems: Fix rtems_task_set_scheduler() API

Task priorities are only valid within a scheduler instance. The
rtems_task_set_scheduler() directive moves a task from one scheduler
instance to another using the current priority of the thread. However,
the current task priority of the source scheduler instance is undefined
in the target scheduler instance. Add a third parameter to specify the
priority.

Close #2749.

Files:
13 edited

Legend:

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

    r8d5b0380 rc0bd006  
    449449
    450450/**
    451  * @brief Sets the scheduler of a task.
    452  *
    453  * The scheduler of a task is initialized to the scheduler of the task that
    454  * created it.
     451 * @brief Sets the scheduler instance of a task.
     452 *
     453 * Initially, the scheduler instance of a task is set to the scheduler instance
     454 * of the task that created it.  This directive allows to move a task from its
     455 * current scheduler instance to another specified by the scheduler identifier.
    455456 *
    456457 * @param[in] task_id Identifier of the task.  Use @ref RTEMS_SELF to select
    457  * the executing task.
    458  * @param[in] scheduler_id Identifier of the scheduler.
     458 *   the executing task.
     459 * @param[in] scheduler_id Identifier of the scheduler instance.
     460 * @param[in] priority The task priority with respect to the new scheduler
     461 *   instance.  The real and initial priority of the task is set to this value.
     462 *   The initial priority is used by rtems_task_restart() for example.
    459463 *
    460464 * @retval RTEMS_SUCCESSFUL Successful operation.
     465 * @retval RTEMS_ILLEGAL_ON_REMOTE_OBJECT Directive is illegal on remote tasks.
    461466 * @retval RTEMS_INVALID_ID Invalid task or scheduler identifier.
     467 * @retval RTEMS_INVALID_PRIORITY Invalid priority.
     468 * @retval RTEMS_RESOURCE_IN_USE The task owns resources which deny a scheduler
     469 *   change.
    462470 *
    463471 * @see rtems_scheduler_ident().
    464472 */
    465473rtems_status_code rtems_task_set_scheduler(
    466   rtems_id task_id,
    467   rtems_id scheduler_id
     474  rtems_id            task_id,
     475  rtems_id            scheduler_id,
     476  rtems_task_priority priority
    468477);
    469478
  • cpukit/rtems/src/tasksetscheduler.c

    r8d5b0380 rc0bd006  
    1717#endif
    1818
    19 #include <rtems/rtems/tasks.h>
     19#include <rtems/rtems/tasksimpl.h>
     20#include <rtems/rtems/statusimpl.h>
    2021#include <rtems/score/schedulerimpl.h>
    2122
    2223rtems_status_code rtems_task_set_scheduler(
    23   rtems_id task_id,
    24   rtems_id scheduler_id
     24  rtems_id            task_id,
     25  rtems_id            scheduler_id,
     26  rtems_task_priority priority
    2527)
    2628{
     
    3133  Per_CPU_Control         *cpu_self;
    3234  void                    *lock;
    33   bool                     ok;
     35  bool                     valid;
     36  Priority_Control         core_priority;
     37  Status_Control           status;
    3438
    3539  if ( !_Scheduler_Get_by_id( scheduler_id, &scheduler ) ) {
    3640    return RTEMS_INVALID_ID;
     41  }
     42
     43  core_priority = _RTEMS_Priority_To_core( scheduler, priority, &valid );
     44  if ( !valid ) {
     45    return RTEMS_INVALID_PRIORITY;
    3746  }
    3847
     
    5564  _Thread_State_acquire_critical( the_thread, &state_lock_context );
    5665
    57   ok = _Scheduler_Set( scheduler, the_thread );
     66  status = _Scheduler_Set( scheduler, the_thread, core_priority );
    5867
    5968  _Thread_State_release_critical( the_thread, &state_lock_context );
    6069  _Thread_Lock_release( lock, &lock_context );
    6170  _Thread_Dispatch_enable( cpu_self );
    62   return ok ? RTEMS_SUCCESSFUL : RTEMS_INCORRECT_STATE;
     71  return _Status_Get( status );
    6372}
  • cpukit/score/include/rtems/score/schedulerimpl.h

    r8d5b0380 rc0bd006  
    2424#include <rtems/score/cpusetimpl.h>
    2525#include <rtems/score/smpimpl.h>
     26#include <rtems/score/status.h>
    2627#include <rtems/score/threadimpl.h>
    2728
     
    577578  (void) cpu_index;
    578579
    579   return true;
    580 #endif
    581 }
    582 
    583 RTEMS_INLINE_ROUTINE bool _Scheduler_Set(
    584   const Scheduler_Control *scheduler,
    585   Thread_Control          *the_thread
    586 )
    587 {
    588 #if defined(RTEMS_SMP)
    589   const Scheduler_Control *current_scheduler;
    590   States_Control           current_state;
    591 
    592   current_scheduler = _Scheduler_Get( the_thread );
    593 
    594   if ( current_scheduler == scheduler ) {
    595     return true;
    596   }
    597 
    598   if ( _Thread_Owns_resources( the_thread ) ) {
    599     return false;
    600   }
    601 
    602   current_state = the_thread->current_state;
    603 
    604   if ( _States_Is_ready( current_state ) ) {
    605     _Scheduler_Block( the_thread );
    606   }
    607 
    608   _Scheduler_Node_destroy( current_scheduler, the_thread );
    609   the_thread->Scheduler.own_control = scheduler;
    610   the_thread->Scheduler.control = scheduler;
    611   _Scheduler_Node_initialize(
    612     scheduler,
    613     the_thread,
    614     the_thread->current_priority
    615   );
    616 
    617   if ( _States_Is_ready( current_state ) ) {
    618     _Scheduler_Unblock( the_thread );
    619   }
    620 
    621   return true;
    622 #else
    623   (void) scheduler;
    624580  return true;
    625581#endif
     
    14731429}
    14741430
     1431RTEMS_INLINE_ROUTINE Status_Control _Scheduler_Set(
     1432  const Scheduler_Control *new_scheduler,
     1433  Thread_Control          *the_thread,
     1434  Priority_Control         priority
     1435)
     1436{
     1437  Scheduler_Node *own_node;
     1438
     1439  if (
     1440    _Thread_Owns_resources( the_thread )
     1441      || the_thread->Wait.queue != NULL
     1442  ) {
     1443    return STATUS_RESOURCE_IN_USE;
     1444  }
     1445
     1446  the_thread->current_priority = priority;
     1447  the_thread->real_priority = priority;
     1448  the_thread->Start.initial_priority = priority;
     1449
     1450  own_node = _Scheduler_Thread_get_own_node( the_thread );
     1451
     1452#if defined(RTEMS_SMP)
     1453  {
     1454    const Scheduler_Control *old_scheduler;
     1455
     1456    old_scheduler = _Scheduler_Get( the_thread );
     1457
     1458    if ( old_scheduler != new_scheduler ) {
     1459      States_Control current_state;
     1460
     1461      current_state = the_thread->current_state;
     1462
     1463      if ( _States_Is_ready( current_state ) ) {
     1464        _Scheduler_Block( the_thread );
     1465      }
     1466
     1467      _Scheduler_Node_destroy( old_scheduler, the_thread );
     1468      the_thread->Scheduler.own_control = new_scheduler;
     1469      the_thread->Scheduler.control = new_scheduler;
     1470      _Scheduler_Node_initialize( new_scheduler, the_thread, priority );
     1471
     1472      if ( _States_Is_ready( current_state ) ) {
     1473        _Scheduler_Unblock( the_thread );
     1474      }
     1475
     1476      return STATUS_SUCCESSFUL;
     1477    }
     1478  }
     1479#endif
     1480
     1481  _Scheduler_Node_set_priority( own_node, priority, false );
     1482  _Scheduler_Update_priority( the_thread );
     1483  return STATUS_SUCCESSFUL;
     1484}
     1485
    14751486/** @} */
    14761487
  • cpukit/score/include/rtems/score/status.h

    r8d5b0380 rc0bd006  
    8484  STATUS_FLUSHED =
    8585    STATUS_BUILD( STATUS_CLASSIC_UNSATISFIED, EAGAIN ),
     86  STATUS_INCORRECT_STATE =
     87    STATUS_BUILD( STATUS_CLASSIC_INCORRECT_STATE, EINVAL ),
    8688  STATUS_INTERRUPTED =
    8789    STATUS_BUILD( STATUS_CLASSIC_INTERNAL_ERROR, EINTR ),
  • testsuites/smptests/smpclock01/init.c

    r8d5b0380 rc0bd006  
    134134  sc = rtems_task_create(
    135135    SCHEDULER_B,
    136     1,
     136    255,
    137137    RTEMS_MINIMUM_STACK_SIZE,
    138138    RTEMS_DEFAULT_MODES,
     
    142142  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    143143
    144   sc = rtems_task_set_scheduler(task_id, scheduler_b_id);
     144  sc = rtems_task_set_scheduler(task_id, scheduler_b_id, 1);
    145145  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    146146
  • testsuites/smptests/smpmigration02/init.c

    r8d5b0380 rc0bd006  
    4747static test_context test_instance;
    4848
     49static rtems_task_priority migration_task_prio(uint32_t task_index)
     50{
     51  return task_index > 0 ? PRIO_LOW : PRIO_HIGH;
     52}
     53
    4954static void migration_task(rtems_task_argument arg)
    5055{
    5156  test_context *ctx = &test_instance;
    52   rtems_status_code sc;
     57  uint32_t task_index = arg;
     58  rtems_task_priority prio = migration_task_prio(task_index);
    5359  uint32_t cpu_count = rtems_get_processor_count();
    5460  uint32_t cpu_index = rtems_get_current_processor();
    5561
    5662  while (true) {
     63    rtems_status_code sc;
     64
    5765    cpu_index = (cpu_index + 1) % cpu_count;
    5866
    59     sc = rtems_task_set_scheduler(RTEMS_SELF, ctx->scheduler_ids[cpu_index]);
    60     rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    61 
    62     ++ctx->counters[arg].value;
     67    sc = rtems_task_set_scheduler(
     68      RTEMS_SELF,
     69      ctx->scheduler_ids[cpu_index],
     70      prio
     71    );
     72    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     73
     74    ++ctx->counters[task_index].value;
    6375
    6476    rtems_test_assert(cpu_index == rtems_get_current_processor());
     
    7890    sc = rtems_task_create(
    7991      rtems_build_name('T', 'A', 'S', 'K'),
    80       task_index > 0 ? PRIO_LOW : PRIO_HIGH,
     92      255,
    8193      RTEMS_MINIMUM_STACK_SIZE,
    8294      RTEMS_DEFAULT_MODES,
     
    8698    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    8799
    88     sc = rtems_task_set_scheduler(task_id, ctx->scheduler_ids[task_index % cpu_count]);
     100    sc = rtems_task_set_scheduler(
     101      task_id,
     102      ctx->scheduler_ids[task_index % cpu_count],
     103      migration_task_prio(task_index)
     104    );
    89105    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    90106
     
    164180    sc = rtems_task_set_scheduler(
    165181      task_id,
    166       ctx->scheduler_ids[cpu_other_index]
     182      ctx->scheduler_ids[cpu_other_index],
     183      2
    167184    );
    168185    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     
    190207    sc = rtems_task_set_scheduler(
    191208      RTEMS_SELF,
    192       ctx->scheduler_ids[cpu_other_index]
     209      ctx->scheduler_ids[cpu_other_index],
     210      1
    193211    );
    194212    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     
    208226    sc = rtems_task_set_scheduler(
    209227      RTEMS_SELF,
    210       ctx->scheduler_ids[cpu_self_index]
     228      ctx->scheduler_ids[cpu_self_index],
     229      1
    211230    );
    212231    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  • testsuites/smptests/smpmrsp01/init.c

    r8d5b0380 rc0bd006  
    419419  sc = rtems_task_create(
    420420    rtems_build_name('W', 'O', 'R', 'K'),
    421     4,
     421    255,
    422422    RTEMS_MINIMUM_STACK_SIZE,
    423423    RTEMS_DEFAULT_MODES,
     
    427427  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    428428
    429   sc = rtems_task_set_scheduler(ctx->worker_ids[0], ctx->scheduler_ids[1]);
     429  sc = rtems_task_set_scheduler(ctx->worker_ids[0], ctx->scheduler_ids[1], 4);
    430430  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    431431
     
    576576  sc = rtems_task_create(
    577577    rtems_build_name('W', 'O', 'R', 'K'),
    578     3,
     578    255,
    579579    RTEMS_MINIMUM_STACK_SIZE,
    580580    RTEMS_DEFAULT_MODES,
     
    584584  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    585585
    586   sc = rtems_task_set_scheduler(ctx->worker_ids[0], ctx->scheduler_ids[1]);
     586  sc = rtems_task_set_scheduler(ctx->worker_ids[0], ctx->scheduler_ids[1], 3);
    587587  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    588588
     
    11531153  sc = rtems_task_create(
    11541154    rtems_build_name('L', 'O', 'W', '0' + i),
    1155     5,
     1155    255,
    11561156    RTEMS_MINIMUM_STACK_SIZE,
    11571157    RTEMS_DEFAULT_MODES,
     
    11611161  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    11621162
    1163   sc = rtems_task_set_scheduler(ctx->low_task_id[i], ctx->scheduler_ids[i]);
     1163  sc = rtems_task_set_scheduler(ctx->low_task_id[i], ctx->scheduler_ids[i], 5);
    11641164  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    11651165
     
    12031203  sc = rtems_task_create(
    12041204    rtems_build_name('H', 'I', 'G', '1'),
    1205     2,
     1205    255,
    12061206    RTEMS_MINIMUM_STACK_SIZE,
    12071207    RTEMS_DEFAULT_MODES,
     
    12111211  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    12121212
    1213   sc = rtems_task_set_scheduler(ctx->high_task_id[1], ctx->scheduler_ids[1]);
     1213  sc = rtems_task_set_scheduler(ctx->high_task_id[1], ctx->scheduler_ids[1], 2);
    12141214  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    12151215
    12161216  sc = rtems_task_create(
    12171217    rtems_build_name('W', 'O', 'R', 'K'),
    1218     4,
     1218    255,
    12191219    RTEMS_MINIMUM_STACK_SIZE,
    12201220    RTEMS_DEFAULT_MODES,
     
    12241224  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    12251225
    1226   sc = rtems_task_set_scheduler(ctx->worker_ids[0], ctx->scheduler_ids[1]);
     1226  sc = rtems_task_set_scheduler(ctx->worker_ids[0], ctx->scheduler_ids[1], 4);
    12271227  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    12281228
     
    13661366  sc = rtems_task_create(
    13671367    rtems_build_name('H', 'E', 'L', 'P'),
    1368     3,
     1368    255,
    13691369    RTEMS_MINIMUM_STACK_SIZE,
    13701370    RTEMS_DEFAULT_MODES,
     
    13761376  sc = rtems_task_set_scheduler(
    13771377    help_task_id,
    1378     ctx->scheduler_ids[1]
     1378    ctx->scheduler_ids[1],
     1379    3
    13791380  );
    13801381  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     
    15501551    uint32_t cpu_index = (v >> 5) % cpu_count;
    15511552
    1552     sc = rtems_task_set_scheduler(RTEMS_SELF, ctx->scheduler_ids[cpu_index]);
     1553    sc = rtems_task_set_scheduler(RTEMS_SELF, ctx->scheduler_ids[cpu_index], 2);
    15531554    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    15541555
     
    16011602    sc = rtems_task_create(
    16021603      'A' + a,
    1603       3 + MRSP_COUNT + a,
     1604      255,
    16041605      RTEMS_MINIMUM_STACK_SIZE,
    16051606      RTEMS_DEFAULT_MODES,
     
    16111612    sc = rtems_task_set_scheduler(
    16121613      ctx->worker_ids[a],
    1613       ctx->scheduler_ids[index]
     1614      ctx->scheduler_ids[index],
     1615      3 + MRSP_COUNT + a
    16141616    );
    16151617    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     
    16241626    sc = rtems_task_create(
    16251627      'A' + b,
    1626       3 + MRSP_COUNT + b,
     1628      255,
    16271629      RTEMS_MINIMUM_STACK_SIZE,
    16281630      RTEMS_DEFAULT_MODES,
     
    16341636    sc = rtems_task_set_scheduler(
    16351637      ctx->worker_ids[b],
    1636       ctx->scheduler_ids[index]
     1638      ctx->scheduler_ids[index],
     1639      3 + MRSP_COUNT + b
    16371640    );
    16381641    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
  • testsuites/smptests/smpmutex01/init.c

    r8d5b0380 rc0bd006  
    8282  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    8383
    84   sc = rtems_task_set_scheduler(ctx->tasks[id], scheduler_id);
     84  sc = rtems_task_set_scheduler(ctx->tasks[id], scheduler_id, prio);
    8585  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    8686
  • testsuites/smptests/smppsxmutex01/init.c

    r8d5b0380 rc0bd006  
    4545  rtems_id scheduler_b_id;
    4646  rtems_status_code sc;
     47  rtems_task_priority prio;
    4748  int prio_ceiling;
    4849  int eno;
     
    5556  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    5657
    57   sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id);
     58  sc = rtems_task_set_priority(pthread_self(), RTEMS_CURRENT_PRIORITY, &prio);
     59  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     60
     61  sc = rtems_task_set_scheduler(pthread_self(), scheduler_b_id, prio);
    5862  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    5963
  • testsuites/smptests/smpscheduler02/init.c

    r8d5b0380 rc0bd006  
    166166
    167167  if (cpu_count > 1) {
    168     sc = rtems_task_set_scheduler(task_id, scheduler_b_id);
    169     rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    170 
    171     sc = rtems_task_set_scheduler(task_id, scheduler_b_id + 1);
     168    sc = rtems_task_set_scheduler(task_id, scheduler_b_id, 1);
     169    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     170
     171    sc = rtems_task_set_scheduler(task_id, scheduler_b_id + 1, 1);
    172172    rtems_test_assert(sc == RTEMS_INVALID_ID);
    173173
     
    201201    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    202202
    203     sc = rtems_task_set_scheduler(task_id, scheduler_b_id);
     203    sc = rtems_task_set_scheduler(task_id, scheduler_b_id, 1);
    204204    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    205205
  • testsuites/smptests/smpscheduler03/init.c

    r8d5b0380 rc0bd006  
    604604    sc = rtems_task_create(
    605605      rtems_build_name('T', 'A', 'S', 'K'),
    606       1,
     606      255,
    607607      RTEMS_MINIMUM_STACK_SIZE,
    608608      RTEMS_DEFAULT_MODES,
     
    615615    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    616616
    617     sc = rtems_task_set_scheduler(ctx->task_id[cpu_index], scheduler_id);
     617    sc = rtems_task_set_scheduler(ctx->task_id[cpu_index], scheduler_id, 1);
    618618    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    619619
  • testsuites/smptests/smpwakeafter01/init.c

    r8d5b0380 rc0bd006  
    9494      sc = rtems_task_create(
    9595        rtems_build_name('T', 'A', 'S', 'K'),
    96         2,
     96        255,
    9797        RTEMS_MINIMUM_STACK_SIZE,
    9898        RTEMS_DEFAULT_MODES,
     
    102102      rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    103103
    104       sc = rtems_task_set_scheduler(task_ids[i][j], scheduler_id);
     104      sc = rtems_task_set_scheduler(task_ids[i][j], scheduler_id, 2);
    105105      rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    106106
  • testsuites/sptests/spscheduler01/init.c

    r8d5b0380 rc0bd006  
    11/*
    2  * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2014, 2016 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    3232static const rtems_id invalid_id = 1;
    3333
     34static rtems_id master_id;
     35
     36static rtems_id sema_id;
     37
    3438static void test_task_get_set_affinity(void)
    3539{
     
    120124}
    121125
    122 static void task(rtems_task_argument arg)
     126static rtems_task_priority set_prio(rtems_id id, rtems_task_priority prio)
     127{
     128  rtems_status_code sc;
     129  rtems_task_priority old_prio;
     130
     131  old_prio = 0xffffffff;
     132  sc = rtems_task_set_priority(id, prio, &old_prio);
     133  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     134
     135  return old_prio;
     136}
     137
     138static void forbidden_task(rtems_task_argument arg)
    123139{
    124140  (void) arg;
     141
     142  rtems_test_assert(0);
     143}
     144
     145static void restart_task(rtems_task_argument arg)
     146{
     147  rtems_status_code sc;
     148
     149  if (arg == 0) {
     150    rtems_test_assert(set_prio(RTEMS_SELF, 3) == 2);
     151
     152    rtems_task_restart(RTEMS_SELF, 1);
     153  } else if (arg == 1) {
     154    rtems_id scheduler_id;
     155
     156    rtems_test_assert(set_prio(RTEMS_SELF, 3) == 2);
     157
     158    sc = rtems_task_get_scheduler(RTEMS_SELF, &scheduler_id);
     159    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     160
     161    sc = rtems_task_set_scheduler(RTEMS_SELF, scheduler_id, 4);
     162    rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     163
     164    rtems_test_assert(set_prio(RTEMS_SELF, 3) == 4);
     165
     166    rtems_task_restart(RTEMS_SELF, 2);
     167  } else {
     168    rtems_test_assert(set_prio(RTEMS_SELF, 3) == 4);
     169
     170    rtems_task_resume(master_id);
     171  }
     172
     173  rtems_test_assert(0);
     174}
     175
     176static void sema_task(rtems_task_argument arg)
     177{
     178  rtems_status_code sc;
     179
     180  sc = rtems_semaphore_obtain(sema_id, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     181  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    125182
    126183  rtems_test_assert(0);
     
    135192  rtems_id scheduler_by_name;
    136193  rtems_id task_id;
     194  rtems_id mtx_id;
    137195
    138196  sc = rtems_scheduler_ident(name, &scheduler_by_name);
     
    157215  rtems_test_assert(scheduler_id == scheduler_by_name);
    158216
    159   sc = rtems_task_set_scheduler(invalid_id, scheduler_id);
    160   rtems_test_assert(sc == RTEMS_INVALID_ID);
    161 
    162   sc = rtems_task_set_scheduler(self_id, invalid_id);
    163   rtems_test_assert(sc == RTEMS_INVALID_ID);
    164 
    165   sc = rtems_task_set_scheduler(self_id, scheduler_id);
     217  sc = rtems_task_set_scheduler(invalid_id, scheduler_id, 1);
     218  rtems_test_assert(sc == RTEMS_INVALID_ID);
     219
     220  sc = rtems_task_set_scheduler(self_id, invalid_id, 1);
     221  rtems_test_assert(sc == RTEMS_INVALID_ID);
     222
     223  sc = rtems_task_set_scheduler(self_id, scheduler_id, UINT32_C(0x80000000));
     224  rtems_test_assert(sc == RTEMS_INVALID_PRIORITY);
     225
     226  sc = rtems_task_set_scheduler(self_id, scheduler_id, 1);
     227  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     228
     229  sc = rtems_semaphore_create(
     230    rtems_build_name(' ', 'M', 'T', 'X'),
     231    0,
     232    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
     233    0,
     234    &mtx_id
     235  );
     236  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     237
     238  sc = rtems_task_set_scheduler(self_id, scheduler_id, 1);
     239  rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE);
     240
     241  sc = rtems_semaphore_release(mtx_id);
     242  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     243
     244  rtems_test_assert(set_prio(self_id, RTEMS_CURRENT_PRIORITY) == 1);
     245
     246  sc = rtems_task_set_scheduler(self_id, scheduler_id, 2);
     247  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     248
     249  rtems_test_assert(set_prio(self_id, RTEMS_CURRENT_PRIORITY) == 2);
     250
     251  sc = rtems_task_set_scheduler(self_id, scheduler_id, 1);
     252  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     253
     254  rtems_test_assert(set_prio(self_id, RTEMS_CURRENT_PRIORITY) == 1);
     255
     256  sc = rtems_semaphore_delete(mtx_id);
    166257  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    167258
     
    182273  rtems_test_assert(scheduler_id == scheduler_by_name);
    183274
    184   sc = rtems_task_set_scheduler(task_id, scheduler_id);
    185   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    186 
    187   sc = rtems_task_start(task_id, task, 0);
    188   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    189 
    190   sc = rtems_task_set_scheduler(task_id, scheduler_id);
     275  sc = rtems_task_set_scheduler(task_id, scheduler_id, 2);
     276  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     277
     278  sc = rtems_task_start(task_id, forbidden_task, 0);
     279  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     280
     281  sc = rtems_task_set_scheduler(task_id, scheduler_id, 2);
     282  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     283
     284  sc = rtems_task_delete(task_id);
     285  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     286
     287  sc = rtems_task_create(
     288    rtems_build_name('T', 'A', 'S', 'K'),
     289    2,
     290    RTEMS_MINIMUM_STACK_SIZE,
     291    RTEMS_DEFAULT_MODES,
     292    RTEMS_DEFAULT_ATTRIBUTES,
     293    &task_id
     294  );
     295  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     296
     297  sc = rtems_task_start(task_id, restart_task, 0);
     298  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     299
     300  sc = rtems_task_suspend(self_id);
     301  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     302
     303  sc = rtems_task_delete(task_id);
     304  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     305
     306  sc = rtems_semaphore_create(
     307    rtems_build_name('S', 'E', 'M', 'A'),
     308    0,
     309    RTEMS_COUNTING_SEMAPHORE,
     310    0,
     311    &sema_id
     312  );
     313  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     314
     315  sc = rtems_task_create(
     316    rtems_build_name('T', 'A', 'S', 'K'),
     317    1,
     318    RTEMS_MINIMUM_STACK_SIZE,
     319    RTEMS_DEFAULT_MODES,
     320    RTEMS_DEFAULT_ATTRIBUTES,
     321    &task_id
     322  );
     323  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     324
     325  sc = rtems_task_start(task_id, sema_task, 0);
     326  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     327
     328  sc = rtems_task_wake_after(RTEMS_YIELD_PROCESSOR);
     329  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     330
     331  sc = rtems_task_set_scheduler(task_id, scheduler_id, 1);
     332  rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE);
     333
     334  sc = rtems_semaphore_delete(sema_id);
    191335  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    192336
     
    276420  rtems_resource_snapshot_take(&snapshot);
    277421
     422  master_id = rtems_task_self();
     423
    278424  test_task_get_set_affinity();
    279425  test_task_get_set_scheduler();
     
    291437
    292438#define CONFIGURE_MAXIMUM_TASKS 2
     439#define CONFIGURE_MAXIMUM_SEMAPHORES 1
    293440
    294441#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
Note: See TracChangeset for help on using the changeset viewer.