Changeset 9c30c31e in rtems for testsuites/smptests


Ignore:
Timestamp:
Nov 16, 2017, 1:38:07 PM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
ec771f2
Parents:
79a998d
Message:

score: Fix _Thread_queue_Flush_critical()

The thread queue extract operations performed by the
_Thread_queue_Flush_critical() may result in a priority change of the
thread queue owner. Carry out the scheduler priority update operation.
This is especially important in SMP configurations.

Close #3236.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/smptests/smpmutex01/init.c

    r79a998d r9c30c31e  
    3939  REQ_MTX_OBTAIN = RTEMS_EVENT_2,
    4040  REQ_MTX_OBTAIN_TIMEOUT = RTEMS_EVENT_3,
    41   REQ_MTX_RELEASE = RTEMS_EVENT_4,
    42   REQ_MTX_2_OBTAIN = RTEMS_EVENT_5,
    43   REQ_MTX_2_RELEASE = RTEMS_EVENT_6,
    44   REQ_SEM_OBTAIN_RELEASE = RTEMS_EVENT_7,
    45   REQ_SEM_RELEASE = RTEMS_EVENT_8,
    46   REQ_SET_DONE = RTEMS_EVENT_9,
    47   REQ_WAIT_FOR_DONE = RTEMS_EVENT_10,
    48   REQ_SEND_EVENT_2 = RTEMS_EVENT_11,
    49   REQ_SEND_EVENT_3 = RTEMS_EVENT_12
     41  REQ_MTX_OBTAIN_UNSATISFIED = RTEMS_EVENT_4,
     42  REQ_MTX_RELEASE = RTEMS_EVENT_5,
     43  REQ_MTX_2_OBTAIN = RTEMS_EVENT_6,
     44  REQ_MTX_2_RELEASE = RTEMS_EVENT_7,
     45  REQ_SEM_OBTAIN_RELEASE = RTEMS_EVENT_8,
     46  REQ_SEM_RELEASE = RTEMS_EVENT_9,
     47  REQ_SET_DONE = RTEMS_EVENT_10,
     48  REQ_WAIT_FOR_DONE = RTEMS_EVENT_11,
     49  REQ_SEND_EVENT_2 = RTEMS_EVENT_12,
     50  REQ_SEND_EVENT_3 = RTEMS_EVENT_13
    5051} request_id;
    5152
     
    249250}
    250251
     252static void obtain_unsatisfied(test_context *ctx)
     253{
     254  rtems_status_code sc;
     255
     256  sc = rtems_semaphore_obtain(ctx->mtx, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
     257  rtems_test_assert(sc == RTEMS_UNSATISFIED);
     258}
     259
    251260static void release(test_context *ctx)
    252261{
     
    254263
    255264  sc = rtems_semaphore_release(ctx->mtx);
     265  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     266}
     267
     268static void flush(test_context *ctx)
     269{
     270  rtems_status_code sc;
     271
     272  sc = rtems_semaphore_flush(ctx->mtx);
    256273  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    257274}
     
    417434    }
    418435
     436    if ((events & REQ_MTX_OBTAIN_UNSATISFIED) != 0) {
     437      obtain_unsatisfied(ctx);
     438      ++ctx->generation[id];
     439    }
     440
    419441    if ((events & REQ_MTX_RELEASE) != 0) {
    420442      release(ctx);
     
    464486  start_task(ctx, A_2_0, worker, 2, SCHED_A);
    465487  start_task(ctx, A_2_1, worker, 2, SCHED_A);
    466   start_task(ctx, B_4, worker, 4, SCHED_B);
    467   start_task(ctx, B_5_0, worker, 5, SCHED_B);
    468   start_task(ctx, B_5_1, worker, 5, SCHED_B);
    469488  start_task(ctx, H_A, helper, 3, SCHED_A);
    470   start_task(ctx, H_B, helper, 6, SCHED_B);
     489
     490  if (rtems_get_processor_count() >= PART_COUNT) {
     491    start_task(ctx, B_4, worker, 4, SCHED_B);
     492    start_task(ctx, B_5_0, worker, 5, SCHED_B);
     493    start_task(ctx, B_5_1, worker, 5, SCHED_B);
     494    start_task(ctx, H_B, helper, 6, SCHED_B);
     495  }
    471496
    472497  sc = rtems_semaphore_create(
     
    509534  request(ctx, A_1, REQ_MTX_RELEASE);
    510535  check_generations(ctx, A_1, NONE);
     536}
     537
     538static void test_flush_inheritance(test_context *ctx)
     539{
     540  assert_prio(ctx, M, 3);
     541  obtain(ctx);
     542  send_event(ctx, A_1, REQ_MTX_OBTAIN_UNSATISFIED);
     543  check_generations(ctx, NONE, NONE);
     544  assert_prio(ctx, M, 1);
     545  flush(ctx);
     546  check_generations(ctx, A_1, NONE);
     547  assert_prio(ctx, M, 3);
     548  release(ctx);
    511549}
    512550
     
    910948}
    911949
    912 static void test(void)
    913 {
    914   test_context *ctx = &test_instance;
    915 
     950static void test(test_context *ctx)
     951{
    916952  test_init(ctx);
    917   test_task_get_priority_not_defined(ctx);
    918   test_simple_inheritance(ctx);
    919   test_dequeue_order_one_scheduler_instance(ctx);
    920   test_mixed_queue_two_scheduler_instances(ctx);
    921   test_mixed_queue_two_scheduler_instances_sem_only(ctx);
    922   test_simple_inheritance_two_scheduler_instances(ctx);
    923   test_nested_inheritance_two_scheduler_instances(ctx);
    924   test_dequeue_order_two_scheduler_instances(ctx);
    925   test_omip_pre_emption(ctx);
    926   test_omip_rescue(ctx);
    927   test_omip_timeout(ctx);
    928   test_omip_yield(ctx);
     953
     954  if (rtems_get_processor_count() >= PART_COUNT) {
     955    test_task_get_priority_not_defined(ctx);
     956    test_simple_inheritance(ctx);
     957    test_dequeue_order_one_scheduler_instance(ctx);
     958    test_mixed_queue_two_scheduler_instances(ctx);
     959    test_mixed_queue_two_scheduler_instances_sem_only(ctx);
     960    test_simple_inheritance_two_scheduler_instances(ctx);
     961    test_nested_inheritance_two_scheduler_instances(ctx);
     962    test_dequeue_order_two_scheduler_instances(ctx);
     963    test_omip_pre_emption(ctx);
     964    test_omip_rescue(ctx);
     965    test_omip_timeout(ctx);
     966    test_omip_yield(ctx);
     967  }
     968
     969  test_flush_inheritance(ctx);
    929970}
    930971
     
    932973{
    933974  TEST_BEGIN();
    934 
    935   if (rtems_get_processor_count() >= PART_COUNT) {
    936     test();
    937   }
    938 
     975  test(&test_instance);
    939976  TEST_END();
    940977  rtems_test_exit(0);
Note: See TracChangeset for help on using the changeset viewer.