On 2013-08-31 03:49, WeiY wrote:
+ while (!stop(ctx)) {
+ while (_Atomic_Compare_exchange_uint(&ctx->global_swap,
&ctx->global_swap_t,
+ worker_index, ATOMIC_ORDER_ACQUIRE, ATOMIC_ORDER_RELEASE)) {
+ /* Wait */
+ }
+ ++counter;
+ ++ctx->flag_counter;
+ ctx->global_swap_t = worker_index;
+ }
This doesn't work since ctx->global_swap_t is a normal variable. Also
the failure memory order is wrong. You try to implement a mutex here.
In case the compare exchange failed, then we try it again thus we don't
care about a particular memory order here (ATOMIC_ORDER_RELAXED). The
success order is all right, since this is the mutex acquire path.
The init and fini handler for the test case don't fit to the body.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : [email protected]
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
_______________________________________________
rtems-devel mailing list
[email protected]
http://www.rtems.org/mailman/listinfo/rtems-devel