diff options
Diffstat (limited to 'samples/nanokernel/benchmark')
8 files changed, 416 insertions, 388 deletions
diff --git a/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c b/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c index fbfa1279a..4bdc38bef 100644 --- a/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c +++ b/samples/nanokernel/benchmark/footprint/src/nanokernel_footprint.c @@ -87,24 +87,24 @@ static char pStack[FIBER_STACK_SIZE]; /* pointer array ensures specified functions are linked into the image */ volatile pfunc func_array[] = { - /* nano timer functions */ + /* nano timer functions */ (pfunc)nano_timer_init, (pfunc)nano_fiber_timer_start, (pfunc)nano_fiber_timer_wait, - /* nano semaphore functions */ + /* nano semaphore functions */ (pfunc)nano_sem_init, (pfunc)nano_fiber_sem_take_wait, (pfunc)nano_fiber_sem_give, #ifdef TEST_max - /* nano LIFO functions */ + /* nano LIFO functions */ (pfunc)nano_lifo_init, (pfunc)nano_fiber_lifo_put, (pfunc)nano_fiber_lifo_get, - /* nano stack functions */ + /* nano stack functions */ (pfunc)nano_stack_init, (pfunc)nano_fiber_stack_push, (pfunc)nano_fiber_stack_pop, - /* nano FIFO functions */ + /* nano FIFO functions */ (pfunc)nano_fifo_init, (pfunc)nano_fiber_fifo_put, (pfunc)nano_fiber_fifo_get, @@ -119,9 +119,9 @@ volatile pfunc func_array[] = { */ void dummyIsr(void *unused) - { +{ ARG_UNUSED(unused); - } +} #ifdef TEST_reg /******************************************************************************* @@ -136,28 +136,27 @@ void dummyIsr(void *unused) */ static void isrDummyIntStub(void *unused) - { +{ ARG_UNUSED(unused); isr_dummy(); CODE_UNREACHABLE; - } +} #endif /* TEST_reg */ /******************************************************************************* * * fiberEntry - trivial fiber * + * @param message Message to be printed. + * @param arg1 Unused. + * * RETURNS: N/A */ -static void fiberEntry - ( - int message, /* message to be printed */ - int arg1 /* unused */ - ) - { +static void fiberEntry(int message, int arg1) +{ ARG_UNUSED(arg1); #ifdef TEST_max @@ -165,7 +164,7 @@ static void fiberEntry #else printk((char *)message); #endif /* TEST_max */ - } +} #endif /* !TEST_min */ @@ -180,19 +179,19 @@ static void fiberEntry */ void main(void) - { +{ #ifdef TEST_max - /* dynamically link in dummy ISR */ + /* dynamically link in dummy ISR */ irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr, - (void *) 0, isrDummyHandlerStub); + (void *) 0, isrDummyHandlerStub); #endif /* TEST_max */ #ifndef TEST_min - /* start a trivial fiber */ + /* start a trivial fiber */ task_fiber_start(pStack, FIBER_STACK_SIZE, fiberEntry, (int) MESSAGE, - (int) func_array, 10, 0); + (int) func_array, 10, 0); #endif /* !TEST_min */ while (1) { - i++; - } + i++; } +} diff --git a/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h b/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h index 427e32051..83570103f 100644 --- a/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h +++ b/samples/nanokernel/benchmark/footprint/src/test_asm_inline_gcc.h @@ -42,7 +42,7 @@ static inline void isr_dummy(void) extern void _IntEnt(void); extern void _IntExit(void); - /* compiler-generated preamble pushes & modifies EBP */ + /* compiler-generated preamble pushes & modifies EBP */ __asm__ volatile ( "pop %%ebp;\n\t" "call _IntEnt;\n\t" diff --git a/samples/nanokernel/benchmark/sys_kernel/src/lifo.c b/samples/nanokernel/benchmark/sys_kernel/src/lifo.c index 09ca249e4..12af810eb 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/lifo.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/lifo.c @@ -47,26 +47,26 @@ static struct nano_fifo nanoFifo_sync; /* for synchronization */ */ void lifo_test_init(void) - { +{ nano_lifo_init(&nanoLifo1); nano_lifo_init(&nanoLifo2); - } +} /******************************************************************************* * * lifo_fiber1 - lifo test context * + * @param par1 Ignored parameter. + * @param par2 Number of test loops. + * * RETURNS: N/A * * \NOMANUAL */ -void lifo_fiber1( - int par1, /* ignored parameter */ - int par2 /* number of test loops */ - ) - { +void lifo_fiber1(int par1, int par2) +{ int i; int element_a[2]; int element_b[2]; @@ -75,84 +75,89 @@ void lifo_fiber1( ARG_UNUSED(par1); for (i = 0; i < par2 / 2; i++) { - pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1); - if (pelement[1] != 2 * i) - break; - element_a[1] = 2 * i; - nano_fiber_lifo_put(&nanoLifo2, element_a); - pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1); - if (pelement[1] != 2 * i + 1) - break; - element_b[1] = 2 * i + 1; - nano_fiber_lifo_put(&nanoLifo2, element_b); + pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1); + if (pelement[1] != 2 * i) { + break; + } + element_a[1] = 2 * i; + nano_fiber_lifo_put(&nanoLifo2, element_a); + pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo1); + if (pelement[1] != 2 * i + 1) { + break; + } + element_b[1] = 2 * i + 1; + nano_fiber_lifo_put(&nanoLifo2, element_b); } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* * * lifo_fiber2 - lifo test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void lifo_fiber2( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void lifo_fiber2(int par1, int par2) +{ int i; int element[2]; int * pelement; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - element[1] = i; - nano_fiber_lifo_put(&nanoLifo1, element); - pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo2); - if (pelement[1] != i) - break; - (*pcounter)++; + element[1] = i; + nano_fiber_lifo_put(&nanoLifo1, element); + pelement = (int *) nano_fiber_lifo_get_wait(&nanoLifo2); + if (pelement[1] != i) { + break; + } + (*pcounter)++; } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* * * lifo_fiber3 - lifo test context * + * @param par1 Address of the counter. + * @param par2 Number of test loops. + * * RETURNS: N/A * * \NOMANUAL */ -void lifo_fiber3( - int par1, /* address of the counter */ - int par2 /* number of test loops */ - ) - { +void lifo_fiber3(int par1, int par2) +{ int i; int element[2]; int * pelement; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - element[1] = i; - nano_fiber_lifo_put(&nanoLifo1, element); - while (NULL == (pelement = (int *) nano_fiber_lifo_get(&nanoLifo2))) - fiber_yield(); - if (pelement[1] != i) - break; - (*pcounter)++; + element[1] = i; + nano_fiber_lifo_put(&nanoLifo1, element); + while (NULL == (pelement = (int *) nano_fiber_lifo_get(&nanoLifo2))) { + fiber_yield(); + } + if (pelement[1] != i) { + break; + } + (*pcounter)++; } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* * @@ -164,7 +169,7 @@ void lifo_fiber3( */ int lifo_test(void) - { +{ uint32_t t; int i = 0; int return_value = 0; @@ -173,12 +178,12 @@ int lifo_test(void) nano_fifo_init(&nanoFifo_sync); - /* test get wait & put fiber functions */ + /* test get wait & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "LIFO channel - 'nano_fiber_lifo_get_wait'"); + "LIFO channel - 'nano_fiber_lifo_get_wait'"); fprintf(output_file, sz_description, - "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," - " 'nano_fiber_lifo_put' functions;"); + "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," + " 'nano_fiber_lifo_put' functions;"); printf(sz_test_start_fmt, "'nano_fiber_lifo_get_wait'"); lifo_test_init(); @@ -186,26 +191,27 @@ int lifo_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, lifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, lifo_fiber2, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } - /* test get/yield & put fiber functions */ + /* test get/yield & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "LIFO channel - 'nano_fiber_lifo_get'"); + "LIFO channel - 'nano_fiber_lifo_get'"); fprintf(output_file, sz_description, - "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," - " 'nano_fiber_lifo_get',\n"); + "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," + " 'nano_fiber_lifo_get',\n"); fprintf(output_file, - "\t'nano_fiber_lifo_put', 'fiber_yield' functions;"); + "\t'nano_fiber_lifo_put', 'fiber_yield' functions;"); printf(sz_test_start_fmt, "'nano_fiber_lifo_get'"); lifo_test_init(); @@ -214,24 +220,25 @@ int lifo_test(void) i = 0; task_fiber_start(fiber_stack1, STACK_SIZE, lifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, lifo_fiber3, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } - /* test get wait & put fiber/task functions */ + /* test get wait & put fiber/task functions */ fprintf(output_file, sz_test_case_fmt, - "LIFO channel - 'nano_task_lifo_get_wait'"); + "LIFO channel - 'nano_task_lifo_get_wait'"); fprintf(output_file, sz_description, - "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," - " 'nano_fiber_lifo_put',\n"); + "testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," + " 'nano_fiber_lifo_put',\n"); fprintf(output_file, "\t'nano_task_lifo_get_wait', 'nano_task_lifo_put' functions;"); printf(sz_test_start_fmt, "'nano_task_lifo_get_wait'"); @@ -240,30 +247,33 @@ int lifo_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, lifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) { - int element[2]; - int * pelement; - element[1] = 2 * i; - nano_task_lifo_put(&nanoLifo1, element); - element[1] = 2 * i + 1; - nano_task_lifo_put(&nanoLifo1, element); - - pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2); - if (pelement[1] != 2 * i + 1) - break; - pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2); - if (pelement[1] != 2 * i) - break; + int element[2]; + int * pelement; + element[1] = 2 * i; + nano_task_lifo_put(&nanoLifo1, element); + element[1] = 2 * i + 1; + nano_task_lifo_put(&nanoLifo1, element); + + pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2); + if (pelement[1] != 2 * i + 1) { + break; + } + pelement = (int *) nano_task_lifo_get_wait(&nanoLifo2); + if (pelement[1] != 2 * i) { + break; + } } t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i * 2, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } return return_value; - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c b/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c index 86738ad48..5122fffb2 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/mwfifo.c @@ -48,10 +48,10 @@ static struct nano_fifo nanoFifo_sync; /* for synchronization */ */ void fifo_test_init(void) - { +{ nano_fifo_init(&nanoFifo1); nano_fifo_init(&nanoFifo2); - } +} /******************************************************************************* @@ -60,29 +60,30 @@ void fifo_test_init(void) * * RETURNS: N/A * + * @param par1 Ignored parameter. + * @param par2 Number of test loops. + * * \NOMANUAL */ -void fifo_fiber1( - int par1, /* ignored parameter */ - int par2 /* number of test loops */ - ) - { +void fifo_fiber1(int par1, int par2) +{ int i; int element[2]; int * pelement; ARG_UNUSED(par1); for (i = 0; i < par2; i++) { - pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo1); - if (pelement[1] != i) - break; - element[1] = i; - nano_fiber_fifo_put(&nanoFifo2, element); + pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo1); + if (pelement[1] != i) { + break; + } + element[1] = i; + nano_fiber_fifo_put(&nanoFifo2, element); } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* @@ -91,30 +92,31 @@ void fifo_fiber1( * * RETURNS: N/A * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * \NOMANUAL */ -void fifo_fiber2( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void fifo_fiber2(int par1, int par2) +{ int i; int element[2]; int * pelement; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - element[1] = i; - nano_fiber_fifo_put(&nanoFifo1, element); - pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo2); - if (pelement[1] != i) - break; - (*pcounter)++; + element[1] = i; + nano_fiber_fifo_put(&nanoFifo1, element); + pelement = (int *) nano_fiber_fifo_get_wait(&nanoFifo2); + if (pelement[1] != i) { + break; + } + (*pcounter)++; } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* @@ -123,31 +125,33 @@ void fifo_fiber2( * * RETURNS: N/A * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * \NOMANUAL */ -void fifo_fiber3( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void fifo_fiber3(int par1, int par2) +{ int i; int element[2]; int * pelement; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - element[1] = i; - nano_fiber_fifo_put(&nanoFifo1, element); - while (NULL == (pelement = (int *) nano_fiber_fifo_get(&nanoFifo2))) - fiber_yield(); - if (pelement[1] != i) - break; - (*pcounter)++; + element[1] = i; + nano_fiber_fifo_put(&nanoFifo1, element); + while (NULL == (pelement = (int *) nano_fiber_fifo_get(&nanoFifo2))) { + fiber_yield(); + } + if (pelement[1] != i) { + break; + } + (*pcounter)++; } - /* wait till it is safe to end: */ + /* wait till it is safe to end: */ nano_fiber_fifo_get_wait(&nanoFifo_sync); - } +} /******************************************************************************* @@ -160,7 +164,7 @@ void fifo_fiber3( */ int fifo_test(void) - { +{ uint32_t t; int i = 0; int return_value = 0; @@ -169,12 +173,12 @@ int fifo_test(void) nano_fifo_init(&nanoFifo_sync); - /* test get wait & put fiber functions */ + /* test get wait & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "FIFO channel - 'nano_fiber_fifo_get_wait'"); + "FIFO channel - 'nano_fiber_fifo_get_wait'"); fprintf(output_file, sz_description, - "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," - " 'nano_fiber_fifo_put' functions;"); + "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," + " 'nano_fiber_fifo_put' functions;"); printf(sz_test_start_fmt, "'nano_fiber_fifo_get_wait'"); fifo_test_init(); @@ -182,26 +186,27 @@ int fifo_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, fifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, fifo_fiber2, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } - /* test get/yield & put fiber functions */ + /* test get/yield & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "FIFO channel - 'nano_fiber_fifo_get'"); + "FIFO channel - 'nano_fiber_fifo_get'"); fprintf(output_file, sz_description, - "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," - " 'nano_fiber_fifo_get',\n"); + "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," + " 'nano_fiber_fifo_get',\n"); fprintf(output_file, - "\t'nano_fiber_fifo_put', 'fiber_yield' functions;"); + "\t'nano_fiber_fifo_put', 'fiber_yield' functions;"); printf(sz_test_start_fmt, "'nano_fiber_fifo_get'"); fifo_test_init(); @@ -210,26 +215,27 @@ int fifo_test(void) i = 0; task_fiber_start(fiber_stack1, STACK_SIZE, fifo_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, fifo_fiber3, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } - /* test get wait & put fiber/task functions */ + /* test get wait & put fiber/task functions */ fprintf(output_file, sz_test_case_fmt, - "FIFO channel - 'nano_task_fifo_get_wait'"); + "FIFO channel - 'nano_task_fifo_get_wait'"); fprintf(output_file, sz_description, - "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," - " 'nano_fiber_fifo_put',\n"); + "testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," + " 'nano_fiber_fifo_put',\n"); fprintf(output_file, - "\t'nano_task_fifo_get_wait', 'nano_task_fifo_put' functions;"); + "\t'nano_task_fifo_get_wait', 'nano_task_fifo_put' functions;"); printf(sz_test_start_fmt, "'nano_task_fifo_get_wait'"); fifo_test_init(); @@ -237,31 +243,34 @@ int fifo_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, fifo_fiber1, 0, - NUMBER_OF_LOOPS / 2, 3, 0); + NUMBER_OF_LOOPS / 2, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, fifo_fiber1, 0, - NUMBER_OF_LOOPS / 2, 3, 0); + NUMBER_OF_LOOPS / 2, 3, 0); for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) { - int element[2]; - int * pelement; - element[1] = i; - nano_task_fifo_put(&nanoFifo1, element); - element[1] = i; - nano_task_fifo_put(&nanoFifo1, element); - - pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2); - if (pelement[1] != i) - break; - pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2); - if (pelement[1] != i) - break; + int element[2]; + int * pelement; + element[1] = i; + nano_task_fifo_put(&nanoFifo1, element); + element[1] = i; + nano_task_fifo_put(&nanoFifo1, element); + + pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2); + if (pelement[1] != i) { + break; + } + pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2); + if (pelement[1] != i) { + break; + } } t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i * 2, t); - /* fiber contexts have done their job, they can stop now safely: */ - for (j = 0; j < 2; j++) - nano_task_fifo_put(&nanoFifo_sync, (void *) element); + /* fiber contexts have done their job, they can stop now safely: */ + for (j = 0; j < 2; j++) { + nano_task_fifo_put(&nanoFifo_sync, (void *) element); + } return return_value; - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/sema.c b/samples/nanokernel/benchmark/sys_kernel/src/sema.c index 9d8093365..6047073e7 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/sema.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/sema.c @@ -45,85 +45,86 @@ struct nano_sem nanoSem2; */ void sema_test_init(void) - { +{ nano_sem_init(&nanoSem1); nano_sem_init(&nanoSem2); - } +} /******************************************************************************* * * sema_fiber1 - semaphore test context * + * @param par1 Ignored parameter. + * @param par2 Number of test loops. + * * RETURNS: N/A * * \NOMANUAL */ -void sema_fiber1( - int par1, /* ignored parameter */ - int par2 /* number of test loops */ - ) - { +void sema_fiber1(int par1, int par2) +{ int i; ARG_UNUSED(par1); for (i = 0; i < par2; i++) { - nano_fiber_sem_take_wait(&nanoSem1); - nano_fiber_sem_give(&nanoSem2); - } + nano_fiber_sem_take_wait(&nanoSem1); + nano_fiber_sem_give(&nanoSem2); } +} /******************************************************************************* * * sema_fiber2 - semaphore test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void sema_fiber2( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void sema_fiber2(int par1, int par2) +{ int i; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - nano_fiber_sem_give(&nanoSem1); - nano_fiber_sem_take_wait(&nanoSem2); - (*pcounter)++; - } + nano_fiber_sem_give(&nanoSem1); + nano_fiber_sem_take_wait(&nanoSem2); + (*pcounter)++; } +} /******************************************************************************* * * sema_fiber3 - semaphore test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void sema_fiber3( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void sema_fiber3(int par1, int par2) +{ int i; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - nano_fiber_sem_give(&nanoSem1); - while (!nano_fiber_sem_take(&nanoSem2)) - fiber_yield(); - (*pcounter)++; - } + nano_fiber_sem_give(&nanoSem1); + while (!nano_fiber_sem_take(&nanoSem2)) { + fiber_yield(); + } + (*pcounter)++; } +} /******************************************************************************* @@ -136,16 +137,16 @@ void sema_fiber3( */ int sema_test(void) - { +{ uint32_t t; int i = 0; int return_value = 0; fprintf(output_file, sz_test_case_fmt, - "Semaphore channel - 'nano_fiber_sem_take_wait'"); + "Semaphore channel - 'nano_fiber_sem_take_wait'"); fprintf(output_file, sz_description, - "testing 'nano_sem_init','nano_fiber_sem_take_wait'," - " 'nano_fiber_sem_give' functions;"); + "testing 'nano_sem_init','nano_fiber_sem_take_wait'," + " 'nano_fiber_sem_give' functions;"); printf(sz_test_start_fmt, "'nano_fiber_sem_take_wait'"); sema_test_init(); @@ -153,18 +154,18 @@ int sema_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, sema_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, sema_fiber2, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); fprintf(output_file, sz_test_case_fmt, - "Semaphore channel - 'nano_fiber_sem_take'"); + "Semaphore channel - 'nano_fiber_sem_take'"); fprintf(output_file, sz_description, - "testing 'nano_sem_init','nano_fiber_sem_take', 'fiber_yield',\n"); + "testing 'nano_sem_init','nano_fiber_sem_take', 'fiber_yield',\n"); fprintf(output_file, "\t'nano_fiber_sem_give' functions;"); printf(sz_test_start_fmt, "'nano_fiber_sem_take'"); @@ -174,21 +175,21 @@ int sema_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, sema_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, sema_fiber3, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); fprintf(output_file, sz_test_case_fmt, - "Semaphore channel - 'nano_task_sem_take_wait'"); + "Semaphore channel - 'nano_task_sem_take_wait'"); fprintf(output_file, sz_description, - "testing 'nano_sem_init','nano_fiber_sem_take_wait'," - " 'nano_fiber_sem_give',\n"); + "testing 'nano_sem_init','nano_fiber_sem_take_wait'," + " 'nano_fiber_sem_give',\n"); fprintf(output_file, - "\t'nano_task_sem_give', 'nano_task_sem_take_wait' functions;"); + "\t'nano_task_sem_give', 'nano_task_sem_take_wait' functions;"); printf(sz_test_start_fmt, "'nano_task_sem_take_wait'"); sema_test_init(); @@ -196,10 +197,10 @@ int sema_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, sema_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); for (i = 0; i < NUMBER_OF_LOOPS; i++) { - nano_task_sem_give(&nanoSem1); - nano_task_sem_take_wait(&nanoSem2); + nano_task_sem_give(&nanoSem1); + nano_task_sem_take_wait(&nanoSem2); } t = TIME_STAMP_DELTA_GET(t); @@ -207,4 +208,4 @@ int sema_test(void) return_value += check_result(i, t); return return_value; - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/stack.c b/samples/nanokernel/benchmark/sys_kernel/src/stack.c index 4fa89d5db..ea13e2440 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/stack.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/stack.c @@ -48,104 +48,109 @@ uint32_t stack2[2]; */ void stack_test_init(void) - { +{ nano_stack_init(&nanoChannel1, stack1); nano_stack_init(&nanoChannel2, stack2); - } +} /******************************************************************************* * * stack_fiber1 - stack test context * + * @param par1 Ignored parameter. + * @param par2 Number of test loops. + * * RETURNS: N/A * * \NOMANUAL */ -void stack_fiber1( - int par1, /* ignored parameter */ - int par2 /* number of test loops */ - ) - { +void stack_fiber1(int par1, int par2) +{ int i; uint32_t data; ARG_UNUSED(par1); for (i = 0; i < par2 / 2; i++) { - data = nano_fiber_stack_pop_wait(&nanoChannel1); - if (data != 2 * i) - break; - data = 2 * i; - nano_fiber_stack_push(&nanoChannel2, data); - data = nano_fiber_stack_pop_wait(&nanoChannel1); - if (data != 2 * i + 1) - break; - data = 2 * i + 1; - nano_fiber_stack_push(&nanoChannel2, data); - } + data = nano_fiber_stack_pop_wait(&nanoChannel1); + if (data != 2 * i) { + break; + } + data = 2 * i; + nano_fiber_stack_push(&nanoChannel2, data); + data = nano_fiber_stack_pop_wait(&nanoChannel1); + if (data != 2 * i + 1) { + break; + } + data = 2 * i + 1; + nano_fiber_stack_push(&nanoChannel2, data); } +} /******************************************************************************* * * stack_fiber2 - stack test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void stack_fiber2( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void stack_fiber2(int par1, int par2) +{ int i; uint32_t data; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - data = i; - nano_fiber_stack_push(&nanoChannel1, data); - data = nano_fiber_stack_pop_wait(&nanoChannel2); - if (data != i) - break; - (*pcounter)++; - } + data = i; + nano_fiber_stack_push(&nanoChannel1, data); + data = nano_fiber_stack_pop_wait(&nanoChannel2); + if (data != i) { + break; + } + (*pcounter)++; } +} /******************************************************************************* * * stack_fiber2 - stack test context * + * @param par1 Address of the counter. + * @param par2 Number of test cycles. + * * RETURNS: N/A * * \NOMANUAL */ -void stack_fiber3( - int par1, /* address of the counter */ - int par2 /* number of test cycles */ - ) - { +void stack_fiber3(int par1, int par2) +{ int i; uint32_t data; int * pcounter = (int *) par1; for (i = 0; i < par2; i++) { - data = i; - nano_fiber_stack_push(&nanoChannel1, data); - data = 0xffffffff; - while (!nano_fiber_stack_pop(&nanoChannel2, &data)) - fiber_yield(); - if (data != i) - break; - (*pcounter)++; - } + data = i; + nano_fiber_stack_push(&nanoChannel1, data); + data = 0xffffffff; + while (!nano_fiber_stack_pop(&nanoChannel2, &data)) { + fiber_yield(); + } + if (data != i) { + break; + } + (*pcounter)++; } +} /******************************************************************************* @@ -158,17 +163,17 @@ void stack_fiber3( */ int stack_test(void) - { +{ uint32_t t; int i = 0; int return_value = 0; - /* test get wait & put fiber functions */ + /* test get wait & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "Stack channel - 'nano_fiber_stack_pop_wait'"); + "Stack channel - 'nano_fiber_stack_pop_wait'"); fprintf(output_file, sz_description, - "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," - " 'nano_fiber_stack_push' functions;"); + "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," + " 'nano_fiber_stack_push' functions;"); printf(sz_test_start_fmt, "'nano_fiber_stack_pop_wait'"); stack_test_init(); @@ -176,22 +181,22 @@ int stack_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, stack_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, stack_fiber2, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* test get/yield & put fiber functions */ + /* test get/yield & put fiber functions */ fprintf(output_file, sz_test_case_fmt, - "Stack channel - 'nano_fiber_stack_pop'"); + "Stack channel - 'nano_fiber_stack_pop'"); fprintf(output_file, sz_description, - "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," - " 'nano_fiber_stack_pop',\n"); + "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," + " 'nano_fiber_stack_pop',\n"); fprintf(output_file, - "\t'nano_fiber_stack_push', 'fiber_yield' functions;"); + "\t'nano_fiber_stack_push', 'fiber_yield' functions;"); printf(sz_test_start_fmt, "'nano_fiber_stack_pop'"); stack_test_init(); @@ -200,22 +205,22 @@ int stack_test(void) i = 0; task_fiber_start(fiber_stack1, STACK_SIZE, stack_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); task_fiber_start(fiber_stack2, STACK_SIZE, stack_fiber3, (int) &i, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); t = TIME_STAMP_DELTA_GET(t); return_value += check_result(i, t); - /* test get wait & put fiber/task functions */ + /* test get wait & put fiber/task functions */ fprintf(output_file, sz_test_case_fmt, - "Stack channel - 'nano_task_stack_pop_wait'"); + "Stack channel - 'nano_task_stack_pop_wait'"); fprintf(output_file, sz_description, - "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," - " 'nano_fiber_stack_push',\n"); + "testing 'nano_stack_init','nano_fiber_stack_pop_wait'," + " 'nano_fiber_stack_push',\n"); fprintf(output_file, - "\t'nano_task_stack_pop_wait', 'nano_task_stack_push' functions;"); + "\t'nano_task_stack_pop_wait', 'nano_task_stack_push' functions;"); printf(sz_test_start_fmt, "'nano_task_stack_pop_wait'"); stack_test_init(); @@ -223,20 +228,22 @@ int stack_test(void) t = BENCH_START(); task_fiber_start(fiber_stack1, STACK_SIZE, stack_fiber1, 0, - NUMBER_OF_LOOPS, 3, 0); + NUMBER_OF_LOOPS, 3, 0); for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) { - uint32_t data; - data = 2 * i; - nano_task_stack_push(&nanoChannel1, data); - data = 2 * i + 1; - nano_task_stack_push(&nanoChannel1, data); - - data = nano_task_stack_pop_wait(&nanoChannel2); - if (data != 2 * i + 1) - break; - data = nano_task_stack_pop_wait(&nanoChannel2); - if (data != 2 * i) - break; + uint32_t data; + data = 2 * i; + nano_task_stack_push(&nanoChannel1, data); + data = 2 * i + 1; + nano_task_stack_push(&nanoChannel1, data); + + data = nano_task_stack_pop_wait(&nanoChannel2); + if (data != 2 * i + 1) { + break; + } + data = nano_task_stack_pop_wait(&nanoChannel2); + if (data != 2 * i) { + break; + } } t = TIME_STAMP_DELTA_GET(t); @@ -244,4 +251,4 @@ int stack_test(void) return_value += check_result(i * 2, t); return return_value; - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c index aff016126..ffd7beea8 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c +++ b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.c @@ -87,13 +87,13 @@ uint32_t tm_off; * \NOMANUAL */ void begin_test(void) - { - /* - Invoke bench_test_start in order to be able to use - tCheck static variable. - */ +{ + /* + * Invoke bench_test_start in order to be able to use + * tCheck static variable. + */ bench_test_start(); - } +} /******************************************************************************* * @@ -101,41 +101,41 @@ void begin_test(void) * * RETURNS: 1 if success and 0 on failure * + * @param i Number of tests. + * @param t Time in ticks for the whole test. + * * \NOMANUAL */ -int check_result( - int i, /* number of tests */ - uint32_t t /* time in ticks for the whole test */ - ) - { - /* - bench_test_end checks tCheck static variable. - bench_test_start modifies it - */ +int check_result(int i, uint32_t t) +{ + /* + * bench_test_end checks tCheck static variable. + * bench_test_start modifies it + */ if (bench_test_end() != 0) { - fprintf(output_file, sz_case_result_fmt, sz_fail); - fprintf(output_file, sz_case_details_fmt, - "timer tick happened. Results are inaccurate"); - fprintf(output_file, sz_case_end_fmt); - return 0; + fprintf(output_file, sz_case_result_fmt, sz_fail); + fprintf(output_file, sz_case_details_fmt, + "timer tick happened. Results are inaccurate"); + fprintf(output_file, sz_case_end_fmt); + return 0; } if (i != NUMBER_OF_LOOPS) { - fprintf(output_file, sz_case_result_fmt, sz_fail); - fprintf(output_file, sz_case_details_fmt, "loop counter = "); - fprintf(output_file, "%i !!!", i); - fprintf(output_file, sz_case_end_fmt); - return 0; + fprintf(output_file, sz_case_result_fmt, sz_fail); + fprintf(output_file, sz_case_details_fmt, "loop counter = "); + fprintf(output_file, "%i !!!", i); + fprintf(output_file, sz_case_end_fmt); + return 0; } fprintf(output_file, sz_case_result_fmt, sz_success); fprintf(output_file, sz_case_details_fmt, - "Average time for 1 iteration: "); + "Average time for 1 iteration: "); fprintf(output_file, sz_case_timing_fmt, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, NUMBER_OF_LOOPS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, NUMBER_OF_LOOPS)); fprintf(output_file, sz_case_end_fmt); return 1; - } +} /******************************************************************************* @@ -159,20 +159,20 @@ int kbhit(void) * * RETURNS: N/A * + * @param continuously Run test till the user presses the key. + * * \NOMANUAL */ -void init_output( - int *continuously /* run test till the user presses the key */ - ) - { +void init_output(int *continuously) +{ ARG_UNUSED(continuously); - /* - * send all printf and fprintf to console - */ + /* + * send all printf and fprintf to console + */ output_file = stdout; - } +} /******************************************************************************* @@ -185,8 +185,8 @@ void init_output( */ void output_close(void) - { - } +{ +} /******************************************************************************* * @@ -202,7 +202,7 @@ void SysKernelBench(void) #else void main(void) #endif - { +{ int continuously = 0; int test_result; @@ -210,31 +210,33 @@ void main(void) bench_test_init(); do { - fprintf(output_file, sz_module_title_fmt, "Nanokernel API test"); - fprintf(output_file, sz_kernel_ver_fmt, kernel_version_get()); - fprintf(output_file, - "\n\nEach test below are repeated %d times and the average\n" - "time for one iteration is displayed.", NUMBER_OF_LOOPS); - - test_result = 0; - - test_result += sema_test(); - test_result += lifo_test(); - test_result += fifo_test(); - test_result += stack_test(); - - if (test_result) { - /* sema, lifo, fifo, stack account for twelve tests in total */ - if (test_result == 12) - fprintf(output_file, sz_module_result_fmt, sz_success); - else - fprintf(output_file, sz_module_result_fmt, sz_partial); - } - else - fprintf(output_file, sz_module_result_fmt, sz_fail); - - } - while (continuously && !kbhit()); + fprintf(output_file, sz_module_title_fmt, "Nanokernel API test"); + fprintf(output_file, sz_kernel_ver_fmt, kernel_version_get()); + fprintf(output_file, + "\n\nEach test below are repeated %d times and the average\n" + "time for one iteration is displayed.", NUMBER_OF_LOOPS); + + test_result = 0; + + test_result += sema_test(); + test_result += lifo_test(); + test_result += fifo_test(); + test_result += stack_test(); + + if (test_result) { + /* sema, lifo, fifo, stack account for twelve tests in total */ + if (test_result == 12) { + fprintf(output_file, sz_module_result_fmt, sz_success); + } + else { + fprintf(output_file, sz_module_result_fmt, sz_partial); + } + } + else { + fprintf(output_file, sz_module_result_fmt, sz_fail); + } + + } while (continuously && !kbhit()); output_close(); - } +} diff --git a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h index 77431f162..051e53860 100644 --- a/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h +++ b/samples/nanokernel/benchmark/sys_kernel/src/syskernel.h @@ -74,12 +74,12 @@ int stack_test(void); void begin_test(void); static inline uint32_t BENCH_START(void) - { +{ uint32_t et; begin_test(); et = TIME_STAMP_DELTA_GET(0); return et; - } +} #endif /* SYSKERNEK_H */ |