Changeset ad7292f in rtems


Ignore:
Timestamp:
Feb 14, 2014, 11:57:53 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
57997d8
Parents:
0344ce03
git-author:
Sebastian Huber <sebastian.huber@…> (02/14/14 11:57:53)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/17/14 07:46:38)
Message:

score: Add SMP barrier

Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/Makefile.am

    r0344ce03 rad7292f  
    6060include_rtems_score_HEADERS += include/rtems/score/schedulersmpimpl.h
    6161include_rtems_score_HEADERS += include/rtems/score/smp.h
     62include_rtems_score_HEADERS += include/rtems/score/smpbarrier.h
    6263include_rtems_score_HEADERS += include/rtems/score/smplock.h
    6364include_rtems_score_HEADERS += include/rtems/score/stack.h
     
    277278
    278279if HAS_SMP
     280libscore_a_SOURCES += src/smpbarrierwait.c
    279281libscore_a_SOURCES += src/threaddispatchdisablelevel.c
    280282endif
  • cpukit/score/preinstall.am

    r0344ce03 rad7292f  
    219219        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smp.h
    220220PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smp.h
     221
     222$(PROJECT_INCLUDE)/rtems/score/smpbarrier.h: include/rtems/score/smpbarrier.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     223        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smpbarrier.h
     224PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smpbarrier.h
    221225
    222226$(PROJECT_INCLUDE)/rtems/score/smplock.h: include/rtems/score/smplock.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
  • testsuites/smptests/smpatomic01/init.c

    r0344ce03 rad7292f  
    11/*
    2  * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    2020
    2121#include <rtems/score/atomic.h>
     22#include <rtems/score/smpbarrier.h>
    2223#include <rtems.h>
    2324#include <string.h>
    2425
    2526#include "tmacros.h"
    26 
    27 /* FIXME: Add barrier to Score */
    28 
    29 typedef struct {
    30         Atomic_Ulong value;
    31         Atomic_Ulong sense;
    32 } SMP_barrier_Control;
    33 
    34 typedef struct {
    35         unsigned long sense;
    36 } SMP_barrier_State;
    37 
    38 #define SMP_BARRIER_CONTROL_INITIALIZER \
    39   { ATOMIC_INITIALIZER_ULONG( 0 ), ATOMIC_INITIALIZER_ULONG( 0 ) }
    40 
    41 #define SMP_BARRIER_STATE_INITIALIZER { 0 }
    42 
    43 static void _SMP_barrier_Wait(
    44   SMP_barrier_Control *control,
    45   SMP_barrier_State *state,
    46   unsigned long count
    47 )
    48 {
    49   unsigned long sense = ~state->sense;
    50   unsigned long previous_value;
    51 
    52   state->sense = sense;
    53 
    54   previous_value = _Atomic_Fetch_add_ulong(
    55     &control->value,
    56     1,
    57     ATOMIC_ORDER_RELAXED
    58   );
    59 
    60   if ( previous_value + 1 == count ) {
    61     _Atomic_Store_ulong( &control->value, 0, ATOMIC_ORDER_RELAXED );
    62     _Atomic_Store_ulong( &control->sense, sense, ATOMIC_ORDER_RELEASE );
    63   } else {
    64     while (
    65       _Atomic_Load_ulong( &control->sense, ATOMIC_ORDER_ACQUIRE ) != sense
    66     ) {
    67       /* Wait */
    68     }
    69   }
    70 }
    7127
    7228#define MASTER_PRIORITY 1
  • testsuites/smptests/smplock01/init.c

    r0344ce03 rad7292f  
    1818
    1919#include <rtems/score/smplock.h>
     20#include <rtems/score/smpbarrier.h>
    2021#include <rtems/score/atomic.h>
    2122#include <rtems.h>
    2223
    2324#include "tmacros.h"
    24 
    25 /* FIXME: Add barrier to Score */
    26 
    27 typedef struct {
    28         Atomic_Uint value;
    29         Atomic_Uint sense;
    30 } barrier_control;
    31 
    32 typedef struct {
    33         unsigned int sense;
    34 } barrier_state;
    35 
    36 #define BARRIER_CONTROL_INITIALIZER \
    37   { ATOMIC_INITIALIZER_UINT(0), ATOMIC_INITIALIZER_UINT(0) }
    38 
    39 #define BARRIER_STATE_INITIALIZER { 0 }
    40 
    41 static void barrier_wait(
    42   barrier_control *control,
    43   barrier_state *state,
    44   unsigned int cpu_count
    45 )
    46 {
    47   unsigned int sense = ~state->sense;
    48   unsigned int value;
    49 
    50   state->sense = sense;
    51 
    52   value = _Atomic_Fetch_add_uint(&control->value, 1, ATOMIC_ORDER_RELAXED);
    53 
    54   if (value + 1 == cpu_count) {
    55     _Atomic_Store_uint(&control->value, 0, ATOMIC_ORDER_RELAXED);
    56     _Atomic_Store_uint(&control->sense, sense, ATOMIC_ORDER_RELEASE);
    57   } else {
    58     while (_Atomic_Load_uint(&control->sense, ATOMIC_ORDER_ACQUIRE) != sense) {
    59       /* Wait */
    60     }
    61   }
    62 }
    6325
    6426#define TASK_PRIORITY 1
     
    7638typedef struct {
    7739  Atomic_Uint state;
    78   barrier_control barrier;
     40  SMP_barrier_Control barrier;
    7941  rtems_id timer_id;
    8042  rtems_interval timeout;
     
    8648static global_context context = {
    8749  .state = ATOMIC_INITIALIZER_UINT(INITIAL),
    88   .barrier = BARRIER_CONTROL_INITIALIZER,
     50  .barrier = SMP_BARRIER_CONTROL_INITIALIZER,
    8951  .lock = SMP_LOCK_INITIALIZER
    9052};
     
    12284  int test,
    12385  global_context *ctx,
    124   barrier_state *bs,
     86  SMP_barrier_State *bs,
    12587  unsigned int cpu_count,
    12688  unsigned int cpu_self
     
    13092  int test,
    13193  global_context *ctx,
    132   barrier_state *bs,
     94  SMP_barrier_State *bs,
    13395  unsigned int cpu_count,
    13496  unsigned int cpu_self
     
    149111  int test,
    150112  global_context *ctx,
    151   barrier_state *bs,
     113  SMP_barrier_State *bs,
    152114  unsigned int cpu_count,
    153115  unsigned int cpu_self
     
    169131  int test,
    170132  global_context *ctx,
    171   barrier_state *bs,
     133  SMP_barrier_State *bs,
    172134  unsigned int cpu_count,
    173135  unsigned int cpu_self
     
    189151  int test,
    190152  global_context *ctx,
    191   barrier_state *bs,
     153  SMP_barrier_State *bs,
    192154  unsigned int cpu_count,
    193155  unsigned int cpu_self
     
    222184  int test,
    223185  global_context *ctx,
    224   barrier_state *bs,
     186  SMP_barrier_State *bs,
    225187  unsigned int cpu_count,
    226188  unsigned int cpu_self
     
    249211static void run_tests(
    250212  global_context *ctx,
    251   barrier_state *bs,
     213  SMP_barrier_State *bs,
    252214  unsigned int cpu_count,
    253215  unsigned int cpu_self,
     
    258220
    259221  for (test = 0; test < TEST_COUNT; ++test) {
    260     barrier_wait(&ctx->barrier, bs, cpu_count);
     222    _SMP_barrier_Wait(&ctx->barrier, bs, cpu_count);
    261223
    262224    if (master) {
     
    277239  }
    278240
    279   barrier_wait(&ctx->barrier, bs, cpu_count);
     241  _SMP_barrier_Wait(&ctx->barrier, bs, cpu_count);
    280242}
    281243
     
    286248  uint32_t cpu_self = rtems_smp_get_current_processor();
    287249  rtems_status_code sc;
    288   barrier_state bs = BARRIER_STATE_INITIALIZER;
     250  SMP_barrier_State bs = SMP_BARRIER_STATE_INITIALIZER;
    289251
    290252  run_tests(ctx, &bs, cpu_count, cpu_self, false);
     
    302264  int test;
    303265  rtems_status_code sc;
    304   barrier_state bs = BARRIER_STATE_INITIALIZER;
     266  SMP_barrier_State bs = SMP_BARRIER_STATE_INITIALIZER;
    305267
    306268  for (cpu = 0; cpu < cpu_count; ++cpu) {
Note: See TracChangeset for help on using the changeset viewer.