zephyr/tests/benchmarks/app_kernel/src/mutex_b.c
Peter Mitsis fa33147bf9 tests: app_kernel: Add user support
Add user thread support to message queue, semaphore, mutex and
pipe tests. Mailbox and memory map tests are restricted from
executing from user threads.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2023-10-31 08:58:45 +01:00

33 lines
661 B
C

/* mutex_b.c */
/*
* Copyright (c) 1997-2010, 2013-2015 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "master.h"
/**
* @brief Mutex lock/unlock test
*/
void mutex_test(void)
{
uint32_t et; /* elapsed time */
int i;
timing_t start;
timing_t end;
PRINT_STRING(dashline);
start = timing_timestamp_get();
for (i = 0; i < NR_OF_MUTEX_RUNS; i++) {
k_mutex_lock(&DEMO_MUTEX, K_FOREVER);
k_mutex_unlock(&DEMO_MUTEX);
}
end = timing_timestamp_get();
et = (uint32_t)timing_cycles_get(&start, &end);
PRINT_F(FORMAT, "average lock and unlock mutex",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS)));
}