1 /* mutex_b.c */
2 
3 /*
4  * Copyright (c) 1997-2010, 2013-2015 Wind River Systems, Inc.
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #include "master.h"
10 
11 /**
12  * @brief Mutex lock/unlock test
13  */
mutex_test(void)14 void mutex_test(void)
15 {
16 	uint32_t et; /* elapsed time */
17 	int i;
18 	timing_t  start;
19 	timing_t  end;
20 
21 	PRINT_STRING(dashline);
22 	start = timing_timestamp_get();
23 	for (i = 0; i < NR_OF_MUTEX_RUNS; i++) {
24 		k_mutex_lock(&DEMO_MUTEX, K_FOREVER);
25 		k_mutex_unlock(&DEMO_MUTEX);
26 	}
27 	end = timing_timestamp_get();
28 	et = (uint32_t)timing_cycles_get(&start, &end);
29 
30 	PRINT_F(FORMAT, "average lock and unlock mutex",
31 		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS)));
32 }
33