Changeset 05b7eec in rtems


Ignore:
Timestamp:
Jun 8, 2016, 1:18:14 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
89f627b5
Parents:
80bbb4ed
git-author:
Sebastian Huber <sebastian.huber@…> (06/08/16 13:18:14)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/09/16 07:39:14)
Message:

score: Add an SMP sequence lock implementation

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/Makefile.am

    r80bbb4ed r05b7eec  
    8383include_rtems_score_HEADERS += include/rtems/score/smpbarrier.h
    8484include_rtems_score_HEADERS += include/rtems/score/smplock.h
     85include_rtems_score_HEADERS += include/rtems/score/smplockseq.h
    8586include_rtems_score_HEADERS += include/rtems/score/smpimpl.h
    8687include_rtems_score_HEADERS += include/rtems/score/stack.h
  • cpukit/score/preinstall.am

    r80bbb4ed r05b7eec  
    296296        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smplock.h
    297297PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smplock.h
     298
     299$(PROJECT_INCLUDE)/rtems/score/smplockseq.h: include/rtems/score/smplockseq.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     300        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/smplockseq.h
     301PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/smplockseq.h
    298302
    299303$(PROJECT_INCLUDE)/rtems/score/smpimpl.h: include/rtems/score/smpimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
  • testsuites/smptests/smplock01/init.c

    r80bbb4ed r05b7eec  
    1919#include <rtems/score/smplock.h>
    2020#include <rtems/score/smplockmcs.h>
     21#include <rtems/score/smplockseq.h>
    2122#include <rtems/score/smpbarrier.h>
    2223#include <rtems/score/atomic.h>
     
    3132#define CPU_COUNT 32
    3233
    33 #define TEST_COUNT 10
     34#define TEST_COUNT 11
    3435
    3536typedef enum {
     
    5152#endif
    5253  SMP_MCS_lock_Control mcs_lock;
     54  SMP_sequence_lock_Control seq_lock;
     55  char unused_space_for_cache_line_separation_0[128];
     56  int a;
     57  char unused_space_for_cache_line_separation_1[128];
     58  int b;
    5359} global_context;
    5460
     
    6066  .mcs_stats = SMP_LOCK_STATS_INITIALIZER("global MCS"),
    6167#endif
    62   .mcs_lock = SMP_MCS_LOCK_INITIALIZER
     68  .mcs_lock = SMP_MCS_LOCK_INITIALIZER,
     69  .seq_lock = SMP_SEQUENCE_LOCK_INITIALIZER
    6370};
    6471
     
    7380  "local MCS lock with global counter",
    7481  "global ticket lock with busy section",
    75   "global MCS lock with busy section"
     82  "global MCS lock with busy section",
     83  "sequence lock"
    7684};
    7785
     
    351359    _SMP_MCS_lock_Release(&ctx->mcs_lock, &lock_context);
    352360    ++counter;
     361  }
     362
     363  ctx->test_counter[test][cpu_self] = counter;
     364}
     365
     366static void test_10_body(
     367  int test,
     368  global_context *ctx,
     369  SMP_barrier_State *bs,
     370  unsigned int cpu_count,
     371  unsigned int cpu_self
     372)
     373{
     374  unsigned long counter = 0;
     375  unsigned long seq;
     376
     377  if (cpu_self == 0) {
     378    while (assert_state(ctx, START_TEST)) {
     379      seq = _SMP_sequence_lock_Write_begin(&ctx->seq_lock);
     380
     381      ctx->a = counter;
     382      ctx->b = counter;
     383
     384      _SMP_sequence_lock_Write_end(&ctx->seq_lock, seq);
     385
     386      ++counter;
     387    }
     388  } else {
     389    while (assert_state(ctx, START_TEST)) {
     390      unsigned long a;
     391      unsigned long b;
     392
     393      do {
     394        seq = _SMP_sequence_lock_Read_begin(&ctx->seq_lock);
     395
     396        a = ctx->a;
     397        b = ctx->b;
     398
     399      } while (_SMP_sequence_lock_Read_retry(&ctx->seq_lock, seq));
     400
     401      ++counter;
     402      rtems_test_assert(a == b);
     403    }
    353404  }
    354405
     
    366417  test_7_body,
    367418  test_8_body,
    368   test_9_body
     419  test_9_body,
     420  test_10_body
    369421};
    370422
  • testsuites/smptests/smplock01/smplock01.scn

    r80bbb4ed r05b7eec  
    11*** BEGIN OF TEST SMPLOCK 1 ***
    2 aquire global lock with local counter
    3         processor 0, local counter 15964
    4         processor 1, local counter 99982377
    5         global counter 0, sum of local counter 99998341
    6 aquire global lock with global counter
    7         processor 0, local counter 166073
    8         processor 1, local counter 99569103
    9         global counter 99735176, sum of local counter 99735176
    10 aquire local lock with local counter
    11         processor 0, local counter 148133948
    12         processor 1, local counter 148148108
    13         global counter 0, sum of local counter 296282056
    14 aquire local lock with global counter
    15         processor 0, local counter 55938783
    16         processor 1, local counter 55951781
    17         global counter 55951781, sum of local counter 111890564
    18 aquire global lock with busy section
    19         processor 0, local counter 10694328
    20         processor 1, local counter 10694346
    21         global counter 0, sum of local counter 21388674
     2global ticket lock with local counter
     3        processor 0, local counter 830091
     4        processor 1, local counter 830090
     5        processor 2, local counter 830091
     6        processor 3, local counter 830091
     7        processor 4, local counter 830091
     8        processor 5, local counter 830091
     9        processor 6, local counter 830091
     10        processor 7, local counter 830091
     11        processor 8, local counter 830089
     12        processor 9, local counter 830088
     13        processor 10, local counter 830090
     14        processor 11, local counter 830090
     15        processor 12, local counter 830090
     16        processor 13, local counter 830092
     17        processor 14, local counter 830093
     18        processor 15, local counter 830092
     19        processor 16, local counter 830092
     20        processor 17, local counter 830092
     21        processor 18, local counter 830089
     22        processor 19, local counter 830092
     23        processor 20, local counter 830090
     24        processor 21, local counter 830090
     25        processor 22, local counter 830090
     26        processor 23, local counter 830092
     27        global counter 0, sum of local counter 19922178
     28global MCS lock with local counter
     29        processor 0, local counter 1579723
     30        processor 1, local counter 1580054
     31        processor 2, local counter 1579890
     32        processor 3, local counter 1579777
     33        processor 4, local counter 1579884
     34        processor 5, local counter 1580005
     35        processor 6, local counter 1578632
     36        processor 7, local counter 1578637
     37        processor 8, local counter 1578774
     38        processor 9, local counter 1578759
     39        processor 10, local counter 1580282
     40        processor 11, local counter 1579885
     41        processor 12, local counter 1580378
     42        processor 13, local counter 1580043
     43        processor 14, local counter 1580115
     44        processor 15, local counter 1580113
     45        processor 16, local counter 1579911
     46        processor 17, local counter 1579993
     47        processor 18, local counter 1580032
     48        processor 19, local counter 1579588
     49        processor 20, local counter 1580049
     50        processor 21, local counter 1580048
     51        processor 22, local counter 1578484
     52        processor 23, local counter 1580013
     53        global counter 0, sum of local counter 37913069
     54global ticket lock with global counter
     55        processor 0, local counter 784729
     56        processor 1, local counter 784730
     57        processor 2, local counter 784730
     58        processor 3, local counter 784730
     59        processor 4, local counter 784731
     60        processor 5, local counter 784730
     61        processor 6, local counter 784731
     62        processor 7, local counter 784730
     63        processor 8, local counter 784731
     64        processor 9, local counter 784729
     65        processor 10, local counter 784729
     66        processor 11, local counter 784730
     67        processor 12, local counter 784731
     68        processor 13, local counter 784729
     69        processor 14, local counter 784728
     70        processor 15, local counter 784730
     71        processor 16, local counter 784729
     72        processor 17, local counter 784730
     73        processor 18, local counter 784730
     74        processor 19, local counter 784729
     75        processor 20, local counter 784729
     76        processor 21, local counter 784729
     77        processor 22, local counter 784729
     78        processor 23, local counter 784731
     79        global counter 18833514, sum of local counter 18833514
     80global MCS lock with global counter
     81        processor 0, local counter 947856
     82        processor 1, local counter 947857
     83        processor 2, local counter 947857
     84        processor 3, local counter 947855
     85        processor 4, local counter 947858
     86        processor 5, local counter 947857
     87        processor 6, local counter 947856
     88        processor 7, local counter 947856
     89        processor 8, local counter 947856
     90        processor 9, local counter 947856
     91        processor 10, local counter 947857
     92        processor 11, local counter 947856
     93        processor 12, local counter 947855
     94        processor 13, local counter 947857
     95        processor 14, local counter 947857
     96        processor 15, local counter 947855
     97        processor 16, local counter 947856
     98        processor 17, local counter 947855
     99        processor 18, local counter 947858
     100        processor 19, local counter 947857
     101        processor 20, local counter 947858
     102        processor 21, local counter 947857
     103        processor 22, local counter 947857
     104        processor 23, local counter 947857
     105        global counter 22748556, sum of local counter 22748556
     106local ticket lock with local counter
     107        processor 0, local counter 77155869
     108        processor 1, local counter 77158831
     109        processor 2, local counter 77081105
     110        processor 3, local counter 77082737
     111        processor 4, local counter 77075777
     112        processor 5, local counter 77076154
     113        processor 6, local counter 77065268
     114        processor 7, local counter 77066500
     115        processor 8, local counter 77106686
     116        processor 9, local counter 77107321
     117        processor 10, local counter 77060207
     118        processor 11, local counter 77062079
     119        processor 12, local counter 77059638
     120        processor 13, local counter 77059931
     121        processor 14, local counter 77056750
     122        processor 15, local counter 77057813
     123        processor 16, local counter 76659137
     124        processor 17, local counter 76659205
     125        processor 18, local counter 76669140
     126        processor 19, local counter 76670415
     127        processor 20, local counter 76674221
     128        processor 21, local counter 76674630
     129        processor 22, local counter 76434805
     130        processor 23, local counter 76434361
     131        global counter 0, sum of local counter 1846208580
     132local MCS lock with local counter
     133        processor 0, local counter 44963740
     134        processor 1, local counter 45045357
     135        processor 2, local counter 45023035
     136        processor 3, local counter 45021994
     137        processor 4, local counter 44912701
     138        processor 5, local counter 44951749
     139        processor 6, local counter 45090697
     140        processor 7, local counter 45089463
     141        processor 8, local counter 45015619
     142        processor 9, local counter 45088716
     143        processor 10, local counter 45064955
     144        processor 11, local counter 45063568
     145        processor 12, local counter 44966963
     146        processor 13, local counter 45002743
     147        processor 14, local counter 45127830
     148        processor 15, local counter 45126512
     149        processor 16, local counter 44947194
     150        processor 17, local counter 44992882
     151        processor 18, local counter 45006760
     152        processor 19, local counter 45005553
     153        processor 20, local counter 44880447
     154        processor 21, local counter 44889042
     155        processor 22, local counter 45036454
     156        processor 23, local counter 45036288
     157        global counter 0, sum of local counter 1080350262
     158local ticket lock with global counter
     159        processor 0, local counter 3962116
     160        processor 1, local counter 3963441
     161        processor 2, local counter 3963482
     162        processor 3, local counter 3963367
     163        processor 4, local counter 3962978
     164        processor 5, local counter 3963102
     165        processor 6, local counter 3962979
     166        processor 7, local counter 3962911
     167        processor 8, local counter 3962974
     168        processor 9, local counter 3963125
     169        processor 10, local counter 3963056
     170        processor 11, local counter 3963093
     171        processor 12, local counter 3962996
     172        processor 13, local counter 3963100
     173        processor 14, local counter 3963096
     174        processor 15, local counter 3963028
     175        processor 16, local counter 3967076
     176        processor 17, local counter 3967251
     177        processor 18, local counter 3967222
     178        processor 19, local counter 3967093
     179        processor 20, local counter 3972862
     180        processor 21, local counter 3972917
     181        processor 22, local counter 3967217
     182        processor 23, local counter 3967220
     183        global counter 7095791, sum of local counter 95157702
     184local MCS lock with global counter
     185        processor 0, local counter 3849478
     186        processor 1, local counter 3860113
     187        processor 2, local counter 3966891
     188        processor 3, local counter 3966750
     189        processor 4, local counter 3973618
     190        processor 5, local counter 4014013
     191        processor 6, local counter 3914674
     192        processor 7, local counter 3914601
     193        processor 8, local counter 3910536
     194        processor 9, local counter 3924908
     195        processor 10, local counter 3995362
     196        processor 11, local counter 3995130
     197        processor 12, local counter 3909912
     198        processor 13, local counter 3923977
     199        processor 14, local counter 3995941
     200        processor 15, local counter 3995667
     201        processor 16, local counter 3842753
     202        processor 17, local counter 3852728
     203        processor 18, local counter 3956029
     204        processor 19, local counter 3955977
     205        processor 20, local counter 3961870
     206        processor 21, local counter 4001067
     207        processor 22, local counter 3911767
     208        processor 23, local counter 3911724
     209        global counter 8503087, sum of local counter 94505486
     210global ticket lock with busy section
     211        processor 0, local counter 614377
     212        processor 1, local counter 614376
     213        processor 2, local counter 614377
     214        processor 3, local counter 614377
     215        processor 4, local counter 614377
     216        processor 5, local counter 614378
     217        processor 6, local counter 614377
     218        processor 7, local counter 614377
     219        processor 8, local counter 614377
     220        processor 9, local counter 614376
     221        processor 10, local counter 614378
     222        processor 11, local counter 614377
     223        processor 12, local counter 614377
     224        processor 13, local counter 614377
     225        processor 14, local counter 614377
     226        processor 15, local counter 614376
     227        processor 16, local counter 614377
     228        processor 17, local counter 614377
     229        processor 18, local counter 614377
     230        processor 19, local counter 614378
     231        processor 20, local counter 614378
     232        processor 21, local counter 614377
     233        processor 22, local counter 614377
     234        processor 23, local counter 614377
     235        global counter 0, sum of local counter 14745049
     236global MCS lock with busy section
     237        processor 0, local counter 552660
     238        processor 1, local counter 552661
     239        processor 2, local counter 552659
     240        processor 3, local counter 552659
     241        processor 4, local counter 552660
     242        processor 5, local counter 552659
     243        processor 6, local counter 552659
     244        processor 7, local counter 552660
     245        processor 8, local counter 552660
     246        processor 9, local counter 552660
     247        processor 10, local counter 552660
     248        processor 11, local counter 552659
     249        processor 12, local counter 552660
     250        processor 13, local counter 552659
     251        processor 14, local counter 552660
     252        processor 15, local counter 552661
     253        processor 16, local counter 552660
     254        processor 17, local counter 552659
     255        processor 18, local counter 552660
     256        processor 19, local counter 552661
     257        processor 20, local counter 552660
     258        processor 21, local counter 552661
     259        processor 22, local counter 552660
     260        processor 23, local counter 552661
     261        global counter 0, sum of local counter 13263838
     262sequence lock
     263        processor 0, local counter 12138641
     264        processor 1, local counter 8
     265        processor 2, local counter 64
     266        processor 3, local counter 89
     267        processor 4, local counter 208
     268        processor 5, local counter 227
     269        processor 6, local counter 69
     270        processor 7, local counter 82
     271        processor 8, local counter 2019
     272        processor 9, local counter 2017
     273        processor 10, local counter 1914
     274        processor 11, local counter 2008
     275        processor 12, local counter 1890
     276        processor 13, local counter 1902
     277        processor 14, local counter 1734
     278        processor 15, local counter 1701
     279        processor 16, local counter 2198
     280        processor 17, local counter 2176
     281        processor 18, local counter 2011
     282        processor 19, local counter 2047
     283        processor 20, local counter 2072
     284        processor 21, local counter 2084
     285        processor 22, local counter 1866
     286        processor 23, local counter 1849
     287        global counter 0, sum of local counter 12170876
    22288*** END OF TEST SMPLOCK 1 ***
Note: See TracChangeset for help on using the changeset viewer.