benchmark: fix sema give/take test

This test has been broken since we've moved from object IDs being
small integers to pointers. The problem was two-fold:

 - The semaphores are not put in a an array anymore, and are thus not
   necessarily referenced. The linker drops them in that case.
 - The semaphores are not necessarily allocated in memory in the order
   they are defined in the mdef file. On x86 actually, they are
   allocated in the reverse order.

There was no need anyway of having all those semaphores: the microkernel
semaphore is a counting semaphore. It can thus simply be given a number
of times anre taken the same number of times to operate on it a
reasonable amount of time to take a measurement.

Change-Id: I67c82cb7eb03d28906f8c63717db8f951818be5e
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
Benjamin Walsh 2016-05-05 14:51:15 -04:00 committed by Anas Nashif
parent 77286b3143
commit f1e90a295c
2 changed files with 7 additions and 62 deletions

View file

@ -10,62 +10,7 @@
% SEMA NAME
% ===============
SEMA INTSEMA
% The first semaphore used in lock/unlock latency test
SEMA SEMASTART
SEMA SEMA001
SEMA SEMA002
SEMA SEMA003
SEMA SEMA004
SEMA SEMA005
SEMA SEMA006
SEMA SEMA007
SEMA SEMA008
SEMA SEMA009
SEMA SEMA010
SEMA SEMA011
SEMA SEMA012
SEMA SEMA013
SEMA SEMA014
SEMA SEMA015
SEMA SEMA016
SEMA SEMA017
SEMA SEMA018
SEMA SEMA019
SEMA SEMA020
SEMA SEMA021
SEMA SEMA022
SEMA SEMA023
SEMA SEMA024
SEMA SEMA025
SEMA SEMA026
SEMA SEMA027
SEMA SEMA028
SEMA SEMA029
SEMA SEMA030
SEMA SEMA031
SEMA SEMA032
SEMA SEMA033
SEMA SEMA034
SEMA SEMA035
SEMA SEMA036
SEMA SEMA037
SEMA SEMA038
SEMA SEMA039
SEMA SEMA040
SEMA SEMA041
SEMA SEMA042
SEMA SEMA043
SEMA SEMA044
SEMA SEMA045
SEMA SEMA046
SEMA SEMA047
SEMA SEMA048
SEMA SEMA049
SEMA SEMA050
SEMA SEMAEND
% The last semaphore used in lock/unlock latency test
% All semaphores between SEMASTART and SEMAEND are
% used in lock/unlock measurements test
SEMA SEMA_LOCK_UNLOCK
% EVENT NAME HANDLER
% ======================

View file

@ -31,8 +31,8 @@
#include <arch/cpu.h>
/* the number of semaphores used in lock/unlock test */
#define N_TEST_SEMA (SEMAEND - SEMASTART)
/* the number of semaphore give/take cycles */
#define N_TEST_SEMA 1000
/* the number of mutex lock/unlock cycles */
#define N_TEST_MUTEX 1000
@ -56,8 +56,8 @@ int microSemaLockUnlock(void)
" that sema");
bench_test_start();
timestamp = TIME_STAMP_DELTA_GET(0);
for (i = SEMASTART; i <= SEMAEND; i++) {
task_sem_give(i);
for (i = 0; i < N_TEST_SEMA; i++) {
task_sem_give(SEMA_LOCK_UNLOCK);
}
timestamp = TIME_STAMP_DELTA_GET(timestamp);
if (bench_test_end() == 0) {
@ -71,8 +71,8 @@ int microSemaLockUnlock(void)
bench_test_start();
timestamp = TIME_STAMP_DELTA_GET(0);
for (i = SEMASTART; i <= SEMAEND; i++) {
task_sem_take(i, TICKS_UNLIMITED);
for (i = 0; i < N_TEST_SEMA; i++) {
task_sem_take(SEMA_LOCK_UNLOCK, TICKS_UNLIMITED);
}
timestamp = TIME_STAMP_DELTA_GET(timestamp);
if (bench_test_end() == 0) {