1 /* sema_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 #ifdef SEMA_BENCH
12 
13 
14 /**
15  *
16  * @brief Semaphore signal speed test
17  *
18  */
sema_test(void)19 void sema_test(void)
20 {
21 	uint32_t et; /* elapsed Time */
22 	int i;
23 
24 	PRINT_STRING(dashline);
25 	et = BENCH_START();
26 	for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
27 	  k_sem_give(&SEM0);
28 	}
29 	et = TIME_STAMP_DELTA_GET(et);
30 	check_result();
31 
32 	PRINT_F(FORMAT, "signal semaphore",
33 		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
34 
35 	k_sem_reset(&SEM1);
36 	k_sem_give(&STARTRCV);
37 
38 	et = BENCH_START();
39 	for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
40 		k_sem_give(&SEM1);
41 	}
42 	et = TIME_STAMP_DELTA_GET(et);
43 	check_result();
44 
45 	PRINT_F(FORMAT, "signal to waiting high pri task",
46 		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
47 
48 	et = BENCH_START();
49 	for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
50 		k_sem_give(&SEM1);
51 	}
52 	et = TIME_STAMP_DELTA_GET(et);
53 	check_result();
54 
55 	PRINT_F(FORMAT, "signal to waiting high pri task, with timeout",
56 		SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS));
57 
58 }
59 
60 #endif /* SEMA_BENCH */
61