summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-10-10 08:47:26 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-10-10 08:49:05 +0200
commit475faef5387417d3bcc274c0ce2634cb128e5583 (patch)
tree66f310c765da3c2b83a6dbfed89b11ba26452038
parentbsp/atsam: Provide default buffer counts (diff)
downloadrtems-475faef5387417d3bcc274c0ce2634cb128e5583.tar.bz2
tmfine01: Add self-contained mutex test case
This demonstrates the effect of false cache line sharing in case of Classic mutexes.
-rw-r--r--testsuites/tmtests/tmfine01/init.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/testsuites/tmtests/tmfine01/init.c b/testsuites/tmtests/tmfine01/init.c
index 18bb97e0c5..c703d76790 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
}
};