Changeset 0ff1c29 in rtems


Ignore:
Timestamp:
Nov 27, 2014, 7:45:10 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
43b09a98
Parents:
5bd822a7
git-author:
Sebastian Huber <sebastian.huber@…> (11/27/14 07:45:10)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/27/14 09:33:31)
Message:

smptests/smpmrsp01: Use busy waits

Use busy waits instead of sleeps to avoid unnecessary switches to the
idle thread.

File:
1 edited

Legend:

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

    r5bd822a7 r0ff1c29  
    7979};
    8080
     81static void busy_wait(void)
     82{
     83  rtems_interval later = rtems_clock_tick_later(2);
     84
     85  while (rtems_clock_tick_before(later)) {
     86    /* Wait */
     87  }
     88}
     89
    8190static void barrier(test_context *ctx, SMP_barrier_State *bs)
    8291{
    8392  _SMP_barrier_Wait(&ctx->barrier, bs, 2);
     93}
     94
     95static void barrier_and_delay(test_context *ctx, SMP_barrier_State *bs)
     96{
     97  barrier(ctx, bs);
     98  busy_wait();
    8499}
    85100
     
    348363
    349364  /* Obtain with timeout (A) */
    350   barrier(ctx, &barrier_state);
    351 
    352   sc = rtems_task_wake_after(2);
    353   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     365  barrier_and_delay(ctx, &barrier_state);
    354366
    355367  assert_prio(ctx->worker_ids[0], 2);
     
    357369
    358370  /* Obtain with priority change and timeout (B) */
    359   barrier(ctx, &barrier_state);
    360 
    361   sc = rtems_task_wake_after(2);
    362   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     371  barrier_and_delay(ctx, &barrier_state);
    363372
    364373  assert_prio(ctx->worker_ids[0], 2);
     
    373382
    374383  /* Obtain without timeout (D) */
    375   barrier(ctx, &barrier_state);
    376 
    377   sc = rtems_task_wake_after(2);
    378   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     384  barrier_and_delay(ctx, &barrier_state);
    379385
    380386  assert_prio(ctx->worker_ids[0], 2);
     
    836842
    837843  /* Worker obtain (F) */
    838   barrier(ctx, &barrier_state);
    839 
    840   sc = rtems_task_wake_after(2);
    841   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     844  barrier_and_delay(ctx, &barrier_state);
    842845
    843846  sc = rtems_task_suspend(ctx->worker_ids[0]);
    844847  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
    845848
    846   sc = rtems_task_wake_after(2);
    847   rtems_test_assert(sc == RTEMS_SUCCESSFUL);
     849  busy_wait();
    848850
    849851  sc = rtems_task_start(
Note: See TracChangeset for help on using the changeset viewer.