Changeset d39ccd69 in rtems


Ignore:
Timestamp:
Sep 1, 2013, 12:34:31 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
7136d7f
Parents:
4238aff
git-author:
Sebastian Huber <sebastian.huber@…> (09/01/13 12:34:31)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/01/13 13:17:01)
Message:

smptests/smpatomic08: Fix compare and exchange

File:
1 edited

Legend:

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

    r4238aff rd39ccd69  
    7979  rtems_id stop_worker_timer_id;
    8080  Atomic_Uint global_uint;
    81   Atomic_Uint global_swap;
    82   uint_fast32_t global_swap_t;
    8381  uint_fast32_t per_worker_uint[CPU_COUNT];
    8482  uint32_t flag_counter;
     
    261259static void test_atomic_compare_exchange_init(test_context *ctx)
    262260{
    263   _Atomic_Init_uint(&ctx->global_swap, 0xffffffff);
    264   ctx->global_swap_t = 0xffffffff;
     261  _Atomic_Init_uint(&ctx->global_uint, 0);
    265262  ctx->flag_counter = 0;
    266263}
     
    271268
    272269  while (!stop(ctx)) {
    273     while (_Atomic_Compare_exchange_uint(&ctx->global_swap, &ctx->global_swap_t,
    274       worker_index, ATOMIC_ORDER_ACQUIRE, ATOMIC_ORDER_RELAXED)) {
    275       /* Wait */
    276     }
     270    bool success;
     271
     272    do {
     273      uint_fast32_t zero = 0;
     274
     275      success = _Atomic_Compare_exchange_uint(
     276        &ctx->global_uint,
     277        &zero,
     278        1,
     279        ATOMIC_ORDER_ACQUIRE,
     280        ATOMIC_ORDER_RELAXED
     281      );
     282    } while (!success);
     283
    277284    ++counter;
    278285    ++ctx->flag_counter;
    279     _Atomic_Store_uint(&ctx->global_swap, 0, ATOMIC_ORDER_RELEASE);
     286
     287    _Atomic_Store_uint(&ctx->global_uint, 0, ATOMIC_ORDER_RELEASE);
    280288  }
    281289
Note: See TracChangeset for help on using the changeset viewer.