diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-02-14 12:57:53 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-02-17 08:46:38 +0100 |
commit | ad7292f26465027cb8fd5494e613f5bd63607623 (patch) | |
tree | 0ccca5c00bc4ca1a4494486f52c5d30f04f7a961 /testsuites/smptests/smpatomic01 | |
parent | score: Use atomic API for SMP lock (diff) | |
download | rtems-ad7292f26465027cb8fd5494e613f5bd63607623.tar.bz2 |
score: Add SMP barrier
Diffstat (limited to 'testsuites/smptests/smpatomic01')
-rw-r--r-- | testsuites/smptests/smpatomic01/init.c | 48 |
1 files changed, 2 insertions, 46 deletions
diff --git a/testsuites/smptests/smpatomic01/init.c b/testsuites/smptests/smpatomic01/init.c index 2901a98e90..792a17bfaf 100644 --- a/testsuites/smptests/smpatomic01/init.c +++ b/testsuites/smptests/smpatomic01/init.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 embedded brains GmbH. All rights reserved. + * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved. * * embedded brains GmbH * Dornierstr. 4 @@ -19,56 +19,12 @@ #endif #include <rtems/score/atomic.h> +#include <rtems/score/smpbarrier.h> #include <rtems.h> #include <string.h> #include "tmacros.h" -/* FIXME: Add barrier to Score */ - -typedef struct { - Atomic_Ulong value; - Atomic_Ulong sense; -} SMP_barrier_Control; - -typedef struct { - unsigned long sense; -} SMP_barrier_State; - -#define SMP_BARRIER_CONTROL_INITIALIZER \ - { ATOMIC_INITIALIZER_ULONG( 0 ), ATOMIC_INITIALIZER_ULONG( 0 ) } - -#define SMP_BARRIER_STATE_INITIALIZER { 0 } - -static void _SMP_barrier_Wait( - SMP_barrier_Control *control, - SMP_barrier_State *state, - unsigned long count -) -{ - unsigned long sense = ~state->sense; - unsigned long previous_value; - - state->sense = sense; - - previous_value = _Atomic_Fetch_add_ulong( - &control->value, - 1, - ATOMIC_ORDER_RELAXED - ); - - if ( previous_value + 1 == count ) { - _Atomic_Store_ulong( &control->value, 0, ATOMIC_ORDER_RELAXED ); - _Atomic_Store_ulong( &control->sense, sense, ATOMIC_ORDER_RELEASE ); - } else { - while ( - _Atomic_Load_ulong( &control->sense, ATOMIC_ORDER_ACQUIRE ) != sense - ) { - /* Wait */ - } - } -} - #define MASTER_PRIORITY 1 #define WORKER_PRIORITY 2 |