[rtems commit] tmfine01: Add self-contained mutex test case

Sebastian Huber sebh at rtems.org
Mon Oct 10 06:49:18 UTC 2016


Module:    rtems
Branch:    master
Commit:    475faef5387417d3bcc274c0ce2634cb128e5583
Changeset: http://git.rtems.org/rtems/commit/?id=475faef5387417d3bcc274c0ce2634cb128e5583

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Oct 10 08:47:26 2016 +0200

tmfine01: Add self-contained mutex test case

This demonstrates the effect of false cache line sharing in case of
Classic mutexes.

---

 testsuites/tmtests/tmfine01/init.c | 47 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/testsuites/tmtests/tmfine01/init.c b/testsuites/tmtests/tmfine01/init.c
index 18bb97e..c703d76 100644
--- a/testsuites/tmtests/tmfine01/init.c
+++ b/testsuites/tmtests/tmfine01/init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2015, 2016 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -18,6 +18,7 @@
 
 #include "tmacros.h"
 
+#include <sys/lock.h>
 #include <stdio.h>
 #include <inttypes.h>
 
@@ -44,6 +45,7 @@ typedef struct {
   uint32_t many_mutex_ops[CPU_COUNT][CPU_COUNT];
   uint32_t self_msg_ops[CPU_COUNT][CPU_COUNT];
   uint32_t many_to_one_msg_ops[CPU_COUNT][CPU_COUNT];
+  uint32_t many_sys_lock_mutex_ops[CPU_COUNT][CPU_COUNT];
 } test_context;
 
 static test_context test_instance;
@@ -368,6 +370,44 @@ static void test_many_to_one_msg_fini(
   );
 }
 
+static void test_many_sys_lock_mutex_body(
+  rtems_test_parallel_context *base,
+  void *arg,
+  size_t active_workers,
+  size_t worker_index
+)
+{
+  test_context *ctx = (test_context *) base;
+  struct _Mutex_Control mtx;
+  uint32_t counter = 0;
+
+  _Mutex_Initialize(&mtx);
+
+  while (!rtems_test_parallel_stop_job(&ctx->base)) {
+    ++counter;
+
+    _Mutex_Acquire(&mtx);
+    _Mutex_Release(&mtx);
+  }
+
+  ctx->many_sys_lock_mutex_ops[active_workers - 1][worker_index] = counter;
+}
+
+static void test_many_sys_lock_mutex_fini(
+  rtems_test_parallel_context *base,
+  void *arg,
+  size_t active_workers
+)
+{
+  test_context *ctx = (test_context *) base;
+
+  test_fini(
+    "ManySysLockMutex",
+    &ctx->many_sys_lock_mutex_ops[active_workers - 1][0],
+    active_workers
+  );
+}
+
 static const rtems_test_parallel_job test_jobs[] = {
   {
     .init = test_init,
@@ -399,6 +439,11 @@ static const rtems_test_parallel_job test_jobs[] = {
     .body = test_many_to_one_msg_body,
     .fini = test_many_to_one_msg_fini,
     .cascade = true
+  }, {
+    .init = test_init,
+    .body = test_many_sys_lock_mutex_body,
+    .fini = test_many_sys_lock_mutex_fini,
+    .cascade = true
   }
 };
 




More information about the vc mailing list