diff options
Diffstat (limited to 'samples/microkernel/benchmark')
33 files changed, 638 insertions, 623 deletions
diff --git a/samples/microkernel/benchmark/app_kernel/src/event_b.c b/samples/microkernel/benchmark/app_kernel/src/event_b.c index 0c5c77f00..b78443997 100644 --- a/samples/microkernel/benchmark/app_kernel/src/event_b.c +++ b/samples/microkernel/benchmark/app_kernel/src/event_b.c @@ -66,7 +66,7 @@ int example_handler (int event); */ void event_test(void) - { +{ int nReturn; int nCounter; uint32_t et; /* elapsed time */ @@ -74,107 +74,107 @@ void event_test(void) PRINT_STRING(dashline, output_file); et = BENCH_START(); for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { - nReturn = task_event_send(TEST_EVENT); + nReturn = task_event_send(TEST_EVENT); #ifdef EVENT_CHECK - if (nReturn != RC_OK) { - PRINT_STRING(EventSignalErr, output_file); - return; /* error */ - } + if (nReturn != RC_OK) { + PRINT_STRING(EventSignalErr, output_file); + return; /* error */ + } #endif /* EVENT_CHECK */ } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "Signal enabled event", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS)); et = BENCH_START(); for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { - nReturn = task_event_send(TEST_EVENT); + nReturn = task_event_send(TEST_EVENT); #ifdef EVENT_CHECK - if (nReturn != RC_OK) { - PRINT_STRING(EventSignalErr, output_file); - task_sleep(SLEEP_TIME); - return; /* error */ - } + if (nReturn != RC_OK) { + PRINT_STRING(EventSignalErr, output_file); + task_sleep(SLEEP_TIME); + return; /* error */ + } #endif /* EVENT_CHECK */ - nReturn = task_event_recv(TEST_EVENT); + nReturn = task_event_recv(TEST_EVENT); #ifdef EVENT_CHECK - if (nReturn != RC_OK) { - PRINT_STRING(EventTestErr, output_file); - task_sleep(SLEEP_TIME); - return; /* error */ - } + if (nReturn != RC_OK) { + PRINT_STRING(EventTestErr, output_file); + task_sleep(SLEEP_TIME); + return; /* error */ + } #endif /* EVENT_CHECK */ } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "Signal event & Test event", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS)); et = BENCH_START(); for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { - nReturn = task_event_send(TEST_EVENT); + nReturn = task_event_send(TEST_EVENT); #ifdef EVENT_CHECK - if (nReturn != RC_OK) { - PRINT_STRING(EventSignalErr, output_file); - return; /* error */ - } + if (nReturn != RC_OK) { + PRINT_STRING(EventSignalErr, output_file); + return; /* error */ + } #endif /* EVENT_CHECK */ - nReturn = task_event_recv_wait(TEST_EVENT); + nReturn = task_event_recv_wait(TEST_EVENT); #ifdef EVENT_CHECK - if (nReturn != RC_OK) { - PRINT_STRING(EventTestErr, output_file); - return; /* error */ - } + if (nReturn != RC_OK) { + PRINT_STRING(EventTestErr, output_file); + return; /* error */ + } #endif /* EVENT_CHECK */ } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "Signal event & TestW event", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_EVENT_RUNS)); PRINT_STRING("| Signal event with installed handler" - " |\n", output_file); + " |\n", output_file); nReturn = task_event_set_handler (TEST_EVENT, example_handler); if (nReturn != RC_OK) { - PRINT_F(output_file, "-------- Error installing event handler.\n"); - task_sleep(SLEEP_TIME); - return; /* error */ + PRINT_F(output_file, "-------- Error installing event handler.\n"); + task_sleep(SLEEP_TIME); + return; /* error */ } for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { - nReturn = task_event_send(TEST_EVENT); + nReturn = task_event_send(TEST_EVENT); #ifdef EVENT_CHECK - if (nReturn != RC_OK) { - PRINT_STRING(EventSignalErr, output_file); - task_sleep(SLEEP_TIME); - return; /* error */ - } - if (nEventValue != TEST_EVENT + 1) { - PRINT_STRING(EventHandlerErr, output_file); - task_sleep(SLEEP_TIME); - return; /* error */ - } + if (nReturn != RC_OK) { + PRINT_STRING(EventSignalErr, output_file); + task_sleep(SLEEP_TIME); + return; /* error */ + } + if (nEventValue != TEST_EVENT + 1) { + PRINT_STRING(EventHandlerErr, output_file); + task_sleep(SLEEP_TIME); + return; /* error */ + } #endif /* EVENT_CHECK */ - nEventValue = 0; + nEventValue = 0; } nReturn = task_event_set_handler (TEST_EVENT, NULL); if (nReturn != RC_OK) { - PRINT_F(output_file, "Error removing event handler.\n"); - task_sleep(SLEEP_TIME); - return; /* error */ + PRINT_F(output_file, "Error removing event handler.\n"); + task_sleep(SLEEP_TIME); + return; /* error */ } PRINT_STRING("| Handler responds OK" - " |\n", - output_file); + " |\n", + output_file); return; /* success */ - } +} /******************************************************************************* @@ -190,10 +190,10 @@ void event_test(void) */ int example_handler (int event) - { +{ nEventValue = event + 1; return 1; - } +} #endif /* EVENT_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/fifo_b.c b/samples/microkernel/benchmark/app_kernel/src/fifo_b.c index a133bbf53..57b2ebd5e 100644 --- a/samples/microkernel/benchmark/app_kernel/src/fifo_b.c +++ b/samples/microkernel/benchmark/app_kernel/src/fifo_b.c @@ -44,73 +44,73 @@ */ void queue_test(void) - { +{ uint32_t et; /* elapsed time */ int i; PRINT_STRING(dashline, output_file); et = BENCH_START(); for (i = 0; i < NR_OF_FIFO_RUNS; i++) { - task_fifo_put_wait(DEMOQX1, data_bench); + task_fifo_put_wait(DEMOQX1, data_bench); } et = TIME_STAMP_DELTA_GET(et); PRINT_F(output_file, FORMAT, "enqueue 1 byte msg in FIFO", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_FIFO_RUNS; i++) { - task_fifo_get_wait(DEMOQX1, data_bench); + task_fifo_get_wait(DEMOQX1, data_bench); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "dequeue 1 byte msg in FIFO", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_FIFO_RUNS; i++) { - task_fifo_put_wait(DEMOQX4, data_bench); + task_fifo_put_wait(DEMOQX4, data_bench); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "enqueue 4 bytes msg in FIFO", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_FIFO_RUNS; i++) { - task_fifo_get_wait(DEMOQX4, data_bench); + task_fifo_get_wait(DEMOQX4, data_bench); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "dequeue 4 bytes msg in FIFO", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); task_sem_give(STARTRCV); et = BENCH_START(); for (i = 0; i < NR_OF_FIFO_RUNS; i++) { - task_fifo_put_wait(DEMOQX1, data_bench); + task_fifo_put_wait(DEMOQX1, data_bench); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, - "enqueue 1 byte msg in FIFO to a waiting higher priority task", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); + "enqueue 1 byte msg in FIFO to a waiting higher priority task", + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_FIFO_RUNS; i++) { - task_fifo_put_wait(DEMOQX4, data_bench); + task_fifo_put_wait(DEMOQX4, data_bench); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, - "enqueue 4 bytes in FIFO to a waiting higher priority task", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); - } + "enqueue 4 bytes in FIFO to a waiting higher priority task", + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_FIFO_RUNS)); +} #endif /* FIFO_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/fifo_r.c b/samples/microkernel/benchmark/app_kernel/src/fifo_r.c index 7d3c4e6ad..185794740 100644 --- a/samples/microkernel/benchmark/app_kernel/src/fifo_r.c +++ b/samples/microkernel/benchmark/app_kernel/src/fifo_r.c @@ -46,16 +46,16 @@ */ void dequtask(void) - { +{ int x, i; for (i = 0; i < NR_OF_FIFO_RUNS; i++) { - task_fifo_get_wait(DEMOQX1, &x); + task_fifo_get_wait(DEMOQX1, &x); } for (i = 0; i < NR_OF_FIFO_RUNS; i++) { - task_fifo_get_wait(DEMOQX4, &x); - } + task_fifo_get_wait(DEMOQX4, &x); } +} #endif /* FIFO_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/mailbox_b.c b/samples/microkernel/benchmark/app_kernel/src/mailbox_b.c index 867cd971c..1af847cae 100644 --- a/samples/microkernel/benchmark/app_kernel/src/mailbox_b.c +++ b/samples/microkernel/benchmark/app_kernel/src/mailbox_b.c @@ -100,7 +100,7 @@ void mailbox_put(uint32_t size, int count, uint32_t *time); */ void mailbox_test(void) - { +{ uint32_t putsize; uint32_t puttime; int putcount; @@ -109,14 +109,14 @@ void mailbox_test(void) PRINT_STRING(dashline, output_file); PRINT_STRING("| " - "M A I L B O X M E A S U R E M E N T S" - " |\n", output_file); + "M A I L B O X M E A S U R E M E N T S" + " |\n", output_file); PRINT_STRING(dashline, output_file); PRINT_STRING("| Send mailbox message to waiting high " - "priority task and wait |\n", output_file); + "priority task and wait |\n", output_file); PRINT_F(output_file, "| repeat for %4d times and take the " - "average |\n", - NR_OF_MBOX_RUNS); + "average |\n", + NR_OF_MBOX_RUNS); PRINT_STRING(dashline, output_file); PRINT_HEADER(); PRINT_STRING(dashline, output_file); @@ -131,14 +131,14 @@ void mailbox_test(void) PRINT_ONE_RESULT(); EmptyMsgPutTime = puttime; for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) { - mailbox_put(putsize, putcount, &puttime); - task_fifo_get_wait(MB_COMM, &getinfo); /* waiting for ack */ - PRINT_ONE_RESULT(); + mailbox_put(putsize, putcount, &puttime); + task_fifo_get_wait(MB_COMM, &getinfo); /* waiting for ack */ + PRINT_ONE_RESULT(); } PRINT_STRING(dashline, output_file); PRINT_OVERHEAD(); PRINT_XFER_RATE(); - } +} /******************************************************************************* @@ -147,15 +147,15 @@ void mailbox_test(void) * * RETURNS: N/A * + * @param size The size of the data chunk. + * @param count Number of data chunks. + * @param time The total time. + * * \NOMANUAL */ -void mailbox_put( - uint32_t size, /* the size of the data chunk */ - int count, /* number of data chunks */ - uint32_t *time /* the total time */ - ) - { +void mailbox_put(uint32_t size, int count, uint32_t *time) +{ int i; unsigned int t; @@ -163,15 +163,15 @@ void mailbox_put( Message.tx_data = data_bench; Message.size = size; - /* first sync with the receiver */ + /* first sync with the receiver */ task_sem_give(SEM0); t = BENCH_START(); for (i = 0; i < count; i++) { - task_mbox_put_wait(MAILB1, 1, &Message); + task_mbox_put_wait(MAILB1, 1, &Message); } t = TIME_STAMP_DELTA_GET(t); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count); check_result(); - } +} #endif /* MAILBOX_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/mailbox_r.c b/samples/microkernel/benchmark/app_kernel/src/mailbox_r.c index edf598a0d..3723d5676 100644 --- a/samples/microkernel/benchmark/app_kernel/src/mailbox_r.c +++ b/samples/microkernel/benchmark/app_kernel/src/mailbox_r.c @@ -56,7 +56,7 @@ int mailbox_get(kmbox_t mailbox,int size,int count,unsigned int* time); */ void mailrecvtask(void) - { +{ int getsize; unsigned int gettime; int getcount; @@ -72,13 +72,13 @@ void mailrecvtask(void) task_fifo_put_wait(MB_COMM, &getinfo); /* acknowledge to master */ for (getsize = 8; getsize <= MESSAGE_SIZE; getsize <<= 1) { - mailbox_get(MAILB1, getsize, getcount, &gettime); - getinfo.time = gettime; - getinfo.size = getsize; - getinfo.count = getcount; - task_fifo_put_wait(MB_COMM, &getinfo); /* acknowledge to master */ - } + mailbox_get(MAILB1, getsize, getcount, &gettime); + getinfo.time = gettime; + getinfo.size = getsize; + getinfo.count = getcount; + task_fifo_put_wait(MB_COMM, &getinfo); /* acknowledge to master */ } +} /******************************************************************************* @@ -87,16 +87,16 @@ void mailrecvtask(void) * * RETURNS: 0 * + * @param mailbox The mailbox to read data from. + * @param size Size of each data portion. + * @param count Number of data portions. + * @param time Resulting time. + * * \NOMANUAL */ -int mailbox_get( - kmbox_t mailbox, /* the mailbox to read data from */ - int size, /* size of each data portion */ - int count, /* number of data portions */ - unsigned int* time /* resulting time */ - ) - { +int mailbox_get(kmbox_t mailbox, int size, int count, unsigned int* time) +{ int i; unsigned int t; struct k_msg Message; @@ -105,18 +105,19 @@ int mailbox_get( Message.rx_data = data_recv; Message.size = size; - /* sync with the sender */ + /* sync with the sender */ task_sem_take_wait(SEM0); t = BENCH_START(); for (i = 0; i < count; i++) { - task_mbox_get_wait(mailbox, &Message); + task_mbox_get_wait(mailbox, &Message); } t = TIME_STAMP_DELTA_GET(t); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count); - if (bench_test_end() < 0) - PRINT_OVERFLOW_ERROR(); - return 0; + if (bench_test_end() < 0) { + PRINT_OVERFLOW_ERROR(); } + return 0; +} #endif /* MAILBOX_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/master.c b/samples/microkernel/benchmark/app_kernel/src/master.c index 3700ec70b..87ab14f3c 100644 --- a/samples/microkernel/benchmark/app_kernel/src/master.c +++ b/samples/microkernel/benchmark/app_kernel/src/master.c @@ -45,8 +45,7 @@ char Msg[MAX_MSG]; char data_bench[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)]; #ifdef PIPE_BENCH -kpipe_t TestPipes[] = { -PIPE_NOBUFF, PIPE_SMALLBUFF, PIPE_BIGBUFF}; +kpipe_t TestPipes[] = {PIPE_NOBUFF, PIPE_SMALLBUFF, PIPE_BIGBUFF}; #endif const char dashline[] = "|--------------------------------------" @@ -83,22 +82,22 @@ int kbhit(void) * * RETURNS: N/A * + * @param continuously Run test till the user presses the key. + * @param autorun Expect user input. + * * \NOMANUAL */ -void init_output( - int *continuously, /* run test till the user presses the key */ - int *autorun /* expect user input */ - ) - { +void init_output(int *continuously, int *autorun) +{ ARG_UNUSED(continuously); ARG_UNUSED(autorun); - /* - * send all printf and fprintf to console - */ + /* + * send all printf and fprintf to console + */ output_file = stdout; - } +} /******************************************************************************* * @@ -110,8 +109,8 @@ void init_output( */ void output_close(void) - { - } +{ +} /* no need to wait for user key press when using console */ #define WAIT_FOR_USER() {} @@ -128,7 +127,7 @@ void output_close(void) /* see config.h to select or to unselect*/ void BenchTask(void) - { +{ int autorun = 0, continuously = 0; init_output(&continuously, &autorun); @@ -136,40 +135,40 @@ void BenchTask(void) PRINT_STRING(newline, output_file); do { - PRINT_STRING(dashline, output_file); - PRINT_STRING("| S I M P L E S E R V I C E " - "M E A S U R E M E N T S | nsec |\n", - output_file); - PRINT_STRING(dashline, output_file); - task_start(RECVTASK); - call_test(); - queue_test(); - sema_test(); - mutex_test(); - memorymap_test(); - mempool_test(); - event_test(); - mailbox_test(); - pipe_test(); - PRINT_STRING("| END OF TESTS " - " |\n", - output_file); - PRINT_STRING(dashline, output_file); - PRINT_STRING("VXMICRO PROJECT EXECUTION SUCCESSFUL\n",output_file); - } - while (continuously && !kbhit()); + PRINT_STRING(dashline, output_file); + PRINT_STRING("| S I M P L E S E R V I C E " + "M E A S U R E M E N T S | nsec |\n", + output_file); + PRINT_STRING(dashline, output_file); + task_start(RECVTASK); + call_test(); + queue_test(); + sema_test(); + mutex_test(); + memorymap_test(); + mempool_test(); + event_test(); + mailbox_test(); + pipe_test(); + PRINT_STRING("| END OF TESTS " + " |\n", + output_file); + PRINT_STRING(dashline, output_file); + PRINT_STRING("VXMICRO PROJECT EXECUTION SUCCESSFUL\n",output_file); + } while (continuously && !kbhit()); WAIT_FOR_USER(); - /* - * Make a 2 second delay. sys_clock_ticks_per_sec in this context is - * a number of system times ticks in a second. - */ - if (autorun) - task_sleep(2 * sys_clock_ticks_per_sec); + /* + * Make a 2 second delay. sys_clock_ticks_per_sec in this context is + * a number of system times ticks in a second. + */ + if (autorun) { + task_sleep(2 * sys_clock_ticks_per_sec); + } output_close(); - } +} /******************************************************************************* @@ -182,6 +181,6 @@ void BenchTask(void) */ void dummy_test(void) - { +{ return; - } +} diff --git a/samples/microkernel/benchmark/app_kernel/src/master.h b/samples/microkernel/benchmark/app_kernel/src/master.h index 33b2d3392..6adc1e1a2 100644 --- a/samples/microkernel/benchmark/app_kernel/src/master.h +++ b/samples/microkernel/benchmark/app_kernel/src/master.h @@ -148,33 +148,31 @@ extern void event_test(void); * is defined in the main file */ -#define PRINT_F(stream, fmt, ...) \ - { \ +#define PRINT_F(stream, fmt, ...) \ +{ \ snprintf(sline, SLINE_LEN, fmt, ##__VA_ARGS__); \ - PRINT_STRING(sline, stream); \ - } + PRINT_STRING(sline, stream); \ +} #define PRINT_OVERFLOW_ERROR() \ - PRINT_F(output_file, \ - __FILE__":%d Error: tick occured\n", __LINE__) + PRINT_F(output_file, __FILE__":%d Error: tick occured\n", __LINE__) static inline uint32_t BENCH_START(void) - { +{ uint32_t et; bench_test_start(); et = TIME_STAMP_DELTA_GET(0); return et; - } +} #define check_result() \ - { \ - if (bench_test_end() < 0) \ - { \ - PRINT_OVERFLOW_ERROR(); \ - return; /* error */ \ - } \ - } +{ \ + if (bench_test_end() < 0) { \ + PRINT_OVERFLOW_ERROR(); \ + return; /* error */ \ + } \ +} #endif /* _MASTER_H */ diff --git a/samples/microkernel/benchmark/app_kernel/src/memmap_b.c b/samples/microkernel/benchmark/app_kernel/src/memmap_b.c index 03e72be19..06777cb61 100644 --- a/samples/microkernel/benchmark/app_kernel/src/memmap_b.c +++ b/samples/microkernel/benchmark/app_kernel/src/memmap_b.c @@ -46,7 +46,7 @@ */ void memorymap_test(void) - { +{ uint32_t et; /* elapsed time */ int i; void* p; @@ -54,14 +54,14 @@ void memorymap_test(void) PRINT_STRING(dashline, output_file); et = BENCH_START(); for (i = 0; i < NR_OF_MAP_RUNS; i++) { - task_mem_map_alloc_wait(MAP1, &p); - task_mem_map_free(MAP1, &p); + task_mem_map_alloc_wait(MAP1, &p); + task_mem_map_free(MAP1, &p); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "average alloc and dealloc memory page", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MAP_RUNS))); - } + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MAP_RUNS))); +} #endif /* MEMMAP_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/mempool_b.c b/samples/microkernel/benchmark/app_kernel/src/mempool_b.c index 6130e3cdb..7401c1652 100644 --- a/samples/microkernel/benchmark/app_kernel/src/mempool_b.c +++ b/samples/microkernel/benchmark/app_kernel/src/mempool_b.c @@ -44,7 +44,7 @@ */ void mempool_test(void) - { +{ uint32_t et; /* elapsed time */ int i; struct k_block block; @@ -52,15 +52,15 @@ void mempool_test(void) PRINT_STRING(dashline, output_file); et = BENCH_START(); for (i = 0; i < NR_OF_POOL_RUNS; i++) { - task_mem_pool_alloc_wait(&block, DEMOPOOL, 16); - task_mem_pool_free(&block); + task_mem_pool_alloc_wait(&block, DEMOPOOL, 16); + task_mem_pool_free(&block); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, - "average alloc and dealloc memory pool block", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_POOL_RUNS))); - } + "average alloc and dealloc memory pool block", + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_POOL_RUNS))); +} #endif /* MEMPOOL_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/mutex_b.c b/samples/microkernel/benchmark/app_kernel/src/mutex_b.c index 4b05baf76..07fcce479 100644 --- a/samples/microkernel/benchmark/app_kernel/src/mutex_b.c +++ b/samples/microkernel/benchmark/app_kernel/src/mutex_b.c @@ -44,21 +44,21 @@ */ void mutex_test(void) - { +{ uint32_t et; /* elapsed time */ int i; PRINT_STRING(dashline, output_file); et = BENCH_START(); for (i = 0; i < NR_OF_MUTEX_RUNS; i++) { - task_mutex_lock_wait(DEMO_MUTEX); - task_mutex_unlock(DEMO_MUTEX); + task_mutex_lock_wait(DEMO_MUTEX); + task_mutex_unlock(DEMO_MUTEX); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "average lock and unlock mutex", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS))); - } + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, (2 * NR_OF_MUTEX_RUNS))); +} #endif /* MUTEX_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/nop_b.c b/samples/microkernel/benchmark/app_kernel/src/nop_b.c index 61e25b322..82c992a8b 100644 --- a/samples/microkernel/benchmark/app_kernel/src/nop_b.c +++ b/samples/microkernel/benchmark/app_kernel/src/nop_b.c @@ -48,19 +48,19 @@ extern void _task_nop(void); */ void call_test(void) - { +{ uint32_t et; /* Elapsed Time */ int i; et = BENCH_START(); for (i = 0; i < NR_OF_NOP_RUNS; i++) { - _task_nop(); + _task_nop(); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "minimum VxMicro call time", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_NOP_RUNS)); - } + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_NOP_RUNS)); +} #endif /* MICROKERNEL_CALL_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/pipe_b.c b/samples/microkernel/benchmark/app_kernel/src/pipe_b.c index 9a71bdc52..dba6168c3 100644 --- a/samples/microkernel/benchmark/app_kernel/src/pipe_b.c +++ b/samples/microkernel/benchmark/app_kernel/src/pipe_b.c @@ -117,7 +117,7 @@ int pipeput(kpipe_t pipe, K_PIPE_OPTION */ void pipe_test(void) - { +{ uint32_t putsize; int getsize; uint32_t puttime[3]; @@ -130,76 +130,76 @@ void pipe_test(void) task_sem_reset(SEM0); task_sem_give(STARTRCV); - /* action: */ + /* action: */ - /* non-buffered operation, matching (ALL_N) */ + /* non-buffered operation, matching (ALL_N) */ PRINT_STRING(dashline, output_file); PRINT_STRING("| " - "C H A N N E L M E A S U R E M E N T S" - " |\n", output_file); + "C H A N N E L M E A S U R E M E N T S" + " |\n", output_file); PRINT_STRING(dashline, output_file); PRINT_STRING("| Send data into a pipe towards a " - "receiving high priority task and wait |\n", - output_file); + "receiving high priority task and wait |\n", + output_file); PRINT_STRING(dashline, output_file); PRINT_STRING("| " - "matching sizes (_ALL_N)" - " |\n", output_file); + "matching sizes (_ALL_N)" + " |\n", output_file); PRINT_STRING(dashline, output_file); PRINT_ALL_TO_N_HEADER_UNIT(); PRINT_STRING(dashline, output_file); PRINT_STRING("| put | get | no buf | small buf| big buf |" - " no buf | small buf| big buf |\n", output_file); + " no buf | small buf| big buf |\n", output_file); PRINT_STRING(dashline, output_file); for (putsize = 8; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) { - for (pipe = 0; pipe < 3; pipe++) { - putcount = NR_OF_PIPE_RUNS; - pipeput(TestPipes[pipe], _ALL_N, putsize, putcount, - &puttime[pipe]); + for (pipe = 0; pipe < 3; pipe++) { + putcount = NR_OF_PIPE_RUNS; + pipeput(TestPipes[pipe], _ALL_N, putsize, putcount, + &puttime[pipe]); - task_fifo_get_wait(CH_COMM, &getinfo); /* waiting for ack */ - } - PRINT_ALL_TO_N(); + task_fifo_get_wait(CH_COMM, &getinfo); /* waiting for ack */ + } + PRINT_ALL_TO_N(); } PRINT_STRING(dashline, output_file); - /* Test with two different sender priorities */ + /* Test with two different sender priorities */ for (prio = 0; prio < 2; prio++) { - /* non-buffered operation, non-matching (1_TO_N) */ - if (prio == 0) { - PRINT_STRING("| " - "non-matching sizes (1_TO_N) to higher priority" - " |\n", output_file); - TaskPrio = task_priority_get(); - } - if (prio == 1) { - PRINT_STRING("| " - "non-matching sizes (1_TO_N) to lower priority" - " |\n", output_file); - task_priority_set(task_id_get(), TaskPrio - 2); - } - PRINT_STRING(dashline, output_file); - PRINT_1_TO_N_HEADER(); - PRINT_STRING("| put | get | no buf | small buf| big buf | " - "no buf | small buf| big buf |\n", output_file); - PRINT_STRING(dashline, output_file); + /* non-buffered operation, non-matching (1_TO_N) */ + if (prio == 0) { + PRINT_STRING("| " + "non-matching sizes (1_TO_N) to higher priority" + " |\n", output_file); + TaskPrio = task_priority_get(); + } + if (prio == 1) { + PRINT_STRING("| " + "non-matching sizes (1_TO_N) to lower priority" + " |\n", output_file); + task_priority_set(task_id_get(), TaskPrio - 2); + } + PRINT_STRING(dashline, output_file); + PRINT_1_TO_N_HEADER(); + PRINT_STRING("| put | get | no buf | small buf| big buf | " + "no buf | small buf| big buf |\n", output_file); + PRINT_STRING(dashline, output_file); - for (putsize = 8; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) { - putcount = MESSAGE_SIZE_PIPE / putsize; - for (pipe = 0; pipe < 3; pipe++) { - pipeput(TestPipes[pipe], _1_TO_N, putsize, - putcount, &puttime[pipe]); - /* size*count == MESSAGE_SIZE_PIPE */ - task_fifo_get_wait(CH_COMM, &getinfo); /* waiting for ack */ - getsize = getinfo.size; + for (putsize = 8; putsize <= (MESSAGE_SIZE_PIPE); putsize <<= 1) { + putcount = MESSAGE_SIZE_PIPE / putsize; + for (pipe = 0; pipe < 3; pipe++) { + pipeput(TestPipes[pipe], _1_TO_N, putsize, + putcount, &puttime[pipe]); + /* size*count == MESSAGE_SIZE_PIPE */ + task_fifo_get_wait(CH_COMM, &getinfo); /* waiting for ack */ + getsize = getinfo.size; + } + PRINT_1_TO_N(); } - PRINT_1_TO_N(); - } - PRINT_STRING(dashline, output_file); - task_priority_set(task_id_get(), TaskPrio); - } + PRINT_STRING(dashline, output_file); + task_priority_set(task_id_get(), TaskPrio); } +} /******************************************************************************* @@ -208,60 +208,63 @@ void pipe_test(void) * * RETURNS: 0 on success, 1 on error * + * @param pipe The pipe to be tested. + * @param option _ALL_TO_N or _1_TO_N. + * @param size Data chunk size. + * @param count Number of data chunks. + * @param time Total write time. + * * \NOMANUAL */ -int pipeput( - kpipe_t pipe, /* The pipe to be tested */ - K_PIPE_OPTION option, /* _ALL_TO_N or _1_TO_N */ - int size, /* data chunk size */ - int count, /* number of data chunks */ - uint32_t *time /* total write time */ - ) - { +int pipeput(kpipe_t pipe, K_PIPE_OPTION option, int size, int count, uint32_t *time) +{ int i; unsigned int t; int sizexferd_total = 0; int size2xfer_total = size * count; - /* first sync with the receiver */ + /* first sync with the receiver */ task_sem_give(SEM0); t = BENCH_START(); for (i = 0; _1_TO_N == option || (i < count); i++) { - int sizexferd = 0; - int size2xfer = min(size, size2xfer_total - sizexferd_total); - int ret; + int sizexferd = 0; + int size2xfer = min(size, size2xfer_total - sizexferd_total); + int ret; - ret = task_pipe_put_wait(pipe, data_bench, size2xfer, - &sizexferd, option); - if (RC_OK != ret) - return 1; - if (_ALL_N == option && sizexferd != size2xfer) - return 1; + ret = task_pipe_put_wait(pipe, data_bench, size2xfer, + &sizexferd, option); + if (RC_OK != ret) { + return 1; + } + if (_ALL_N == option && sizexferd != size2xfer) { + return 1; + } - sizexferd_total += sizexferd; - if (size2xfer_total == sizexferd_total) - break; + sizexferd_total += sizexferd; + if (size2xfer_total == sizexferd_total) { + break; + } - if (size2xfer_total < sizexferd_total) - return 1; + if (size2xfer_total < sizexferd_total) { + return 1; + } } t = TIME_STAMP_DELTA_GET(t); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count); if (bench_test_end() < 0) { - if (high_timer_overflow()) { - PRINT_STRING("| Timer overflow. Results are invalid ", - output_file); - } - else { - PRINT_STRING("| Tick occured. Results may be inaccurate ", - output_file); - } - PRINT_STRING(" |\n", - output_file); + if (high_timer_overflow()) { + PRINT_STRING("| Timer overflow. Results are invalid ", + output_file); + } + else { + PRINT_STRING("| Tick occured. Results may be inaccurate ", + output_file); + } + PRINT_STRING(" |\n", output_file); } return 0; - } +} #endif /* PIPE_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/pipe_r.c b/samples/microkernel/benchmark/app_kernel/src/pipe_r.c index 1737d4301..7aa8322cd 100644 --- a/samples/microkernel/benchmark/app_kernel/src/pipe_r.c +++ b/samples/microkernel/benchmark/app_kernel/src/pipe_r.c @@ -39,7 +39,7 @@ * Function prototypes. */ int pipeget(kpipe_t pipe, K_PIPE_OPTION option, - int size, int count, unsigned int* time); + int size, int count, unsigned int* time); /* * Function declarations. @@ -57,7 +57,7 @@ int pipeget(kpipe_t pipe, K_PIPE_OPTION option, */ void piperecvtask(void) - { +{ int getsize; unsigned int gettime; int getcount; @@ -65,37 +65,37 @@ void piperecvtask(void) int prio; GetInfo getinfo; - /* matching (ALL_N) */ + /* matching (ALL_N) */ for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) { - for (pipe = 0; pipe < 3; pipe++) { - getcount = NR_OF_PIPE_RUNS; - pipeget(TestPipes[pipe], _ALL_N, getsize, - getcount, &gettime); - getinfo.time = gettime; - getinfo.size = getsize; - getinfo.count = getcount; - task_fifo_put_wait(CH_COMM, &getinfo); /* acknowledge to master */ - } + for (pipe = 0; pipe < 3; pipe++) { + getcount = NR_OF_PIPE_RUNS; + pipeget(TestPipes[pipe], _ALL_N, getsize, + getcount, &gettime); + getinfo.time = gettime; + getinfo.size = getsize; + getinfo.count = getcount; + task_fifo_put_wait(CH_COMM, &getinfo); /* acknowledge to master */ + } } for (prio = 0; prio < 2; prio++) { - /* non-matching (1_TO_N) */ - for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) { - getcount = MESSAGE_SIZE_PIPE / getsize; - for (pipe = 0; pipe < 3; pipe++) { - /* size*count == MESSAGE_SIZE_PIPE */ - pipeget(TestPipes[pipe], _1_TO_N, - getsize, getcount, &gettime); - getinfo.time = gettime; - getinfo.size = getsize; - getinfo.count = getcount; - task_fifo_put_wait(CH_COMM, &getinfo); /* acknowledge to master */ + /* non-matching (1_TO_N) */ + for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) { + getcount = MESSAGE_SIZE_PIPE / getsize; + for (pipe = 0; pipe < 3; pipe++) { + /* size*count == MESSAGE_SIZE_PIPE */ + pipeget(TestPipes[pipe], _1_TO_N, + getsize, getcount, &gettime); + getinfo.time = gettime; + getinfo.size = getsize; + getinfo.count = getcount; + task_fifo_put_wait(CH_COMM, &getinfo); /* acknowledge to master */ + } } - } } - } +} /******************************************************************************* @@ -104,61 +104,66 @@ void piperecvtask(void) * * RETURNS: 0 on success, 1 on error * + * @param pipe Pipe to read data from. + * @param option _ALL_TO_N or _1_TO_N. + * @param size Data chunk size. + * @param count Number of data chunks. + * @param time Total write time. + * * \NOMANUAL */ -int pipeget( - kpipe_t pipe, /* pipe to read data from */ - K_PIPE_OPTION option, /* _ALL_TO_N or _1_TO_N */ - int size, /* data chunk size */ - int count, /* number of data chunks */ - unsigned int* time /* total write time */ - ) - { +int pipeget(kpipe_t pipe, K_PIPE_OPTION option, int size, int count, + unsigned int* time) +{ int i; unsigned int t; int sizexferd_total = 0; int size2xfer_total = size * count; - /* sync with the sender */ + /* sync with the sender */ task_sem_take_wait(SEM0); t = BENCH_START(); for (i = 0; _1_TO_N == option || (i < count); i++) { - int sizexferd = 0; - int size2xfer = min(size, size2xfer_total - sizexferd_total); - int ret; - - ret = task_pipe_get_wait(pipe, data_recv, size2xfer, - &sizexferd, option); - if (RC_OK != ret) - return 1; + int sizexferd = 0; + int size2xfer = min(size, size2xfer_total - sizexferd_total); + int ret; + + ret = task_pipe_get_wait(pipe, data_recv, size2xfer, + &sizexferd, option); + if (RC_OK != ret) { + return 1; + } - if (_ALL_N == option && sizexferd != size2xfer) - return 1; + if (_ALL_N == option && sizexferd != size2xfer) { + return 1; + } - sizexferd_total += sizexferd; - if (size2xfer_total == sizexferd_total) - break; + sizexferd_total += sizexferd; + if (size2xfer_total == sizexferd_total) { + break; + } - if (size2xfer_total < sizexferd_total) - return 1; + if (size2xfer_total < sizexferd_total) { + return 1; + } } t = TIME_STAMP_DELTA_GET(t); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG(t, count); if (bench_test_end() < 0) { - if (high_timer_overflow()) { - PRINT_STRING("| Timer overflow. Results are invalid ", - output_file); - } - else { - PRINT_STRING("| Tick occured. Results may be inaccurate ", - output_file); - } - PRINT_STRING(" |\n", - output_file); + if (high_timer_overflow()) { + PRINT_STRING("| Timer overflow. Results are invalid ", + output_file); + } + else { + PRINT_STRING("| Tick occured. Results may be inaccurate ", + output_file); + } + PRINT_STRING(" |\n", + output_file); } return 0; - } +} #endif /* PIPE_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/receiver.c b/samples/microkernel/benchmark/app_kernel/src/receiver.c index 8f543d9d6..1e51fe9f1 100644 --- a/samples/microkernel/benchmark/app_kernel/src/receiver.c +++ b/samples/microkernel/benchmark/app_kernel/src/receiver.c @@ -41,9 +41,7 @@ #include "receiver.h" -char data_recv[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)] = { - 0 - }; +char data_recv[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)] = { 0 }; void dequtask(void); void waittask(void); @@ -60,8 +58,8 @@ void piperecvtask(void); */ void recvtask(void) - { - /* order must be compatible with master.c ! */ +{ + /* order must be compatible with master.c ! */ #ifdef FIFO_BENCH task_sem_take_wait(STARTRCV); dequtask(); @@ -78,4 +76,4 @@ void recvtask(void) task_sem_take_wait(STARTRCV); piperecvtask(); #endif - } +} diff --git a/samples/microkernel/benchmark/app_kernel/src/receiver.h b/samples/microkernel/benchmark/app_kernel/src/receiver.h index b1da20f7e..c025692c3 100644 --- a/samples/microkernel/benchmark/app_kernel/src/receiver.h +++ b/samples/microkernel/benchmark/app_kernel/src/receiver.h @@ -42,7 +42,7 @@ typedef struct { int count; unsigned int time; int size; - } GetInfo; +} GetInfo; /* global data */ extern char data_recv[OCTET_TO_SIZEOFUNIT(MESSAGE_SIZE)]; diff --git a/samples/microkernel/benchmark/app_kernel/src/sema_b.c b/samples/microkernel/benchmark/app_kernel/src/sema_b.c index e63fd7592..94c085aa7 100644 --- a/samples/microkernel/benchmark/app_kernel/src/sema_b.c +++ b/samples/microkernel/benchmark/app_kernel/src/sema_b.c @@ -45,104 +45,104 @@ */ void sema_test(void) - { +{ uint32_t et; /* elapsed Time */ int i; PRINT_STRING(dashline, output_file); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - task_sem_give(SEM0); + task_sem_give(SEM0); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal semaphore", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); task_sem_reset(SEM1); task_sem_give(STARTRCV); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - task_sem_give(SEM1); + task_sem_give(SEM1); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waiting high pri task", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - task_sem_give(SEM1); + task_sem_give(SEM1); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, - "signal to waiting high pri task, with timeout", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); + "signal to waiting high pri task, with timeout", + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - task_sem_give(SEM2); + task_sem_give(SEM2); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (2)", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - task_sem_give(SEM2); + task_sem_give(SEM2); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (2), with timeout", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - task_sem_give(SEM3); + task_sem_give(SEM3); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (3)", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - task_sem_give(SEM3); + task_sem_give(SEM3); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (3), with timeout", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - task_sem_give(SEM4); + task_sem_give(SEM4); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (4)", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); et = BENCH_START(); for (i = 0; i < NR_OF_SEMA_RUNS; i++) { - task_sem_give(SEM4); + task_sem_give(SEM4); } et = TIME_STAMP_DELTA_GET(et); check_result(); PRINT_F(output_file, FORMAT, "signal to waitm (4), with timeout", - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); - } + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(et, NR_OF_SEMA_RUNS)); +} #endif /* SEMA_BENCH */ diff --git a/samples/microkernel/benchmark/app_kernel/src/sema_r.c b/samples/microkernel/benchmark/app_kernel/src/sema_r.c index c08d27779..5b02dc263 100644 --- a/samples/microkernel/benchmark/app_kernel/src/sema_r.c +++ b/samples/microkernel/benchmark/app_kernel/src/sema_r.c @@ -47,7 +47,7 @@ */ void waittask(void) - { +{ int i; ksem_t slist[5]; @@ -58,27 +58,35 @@ void waittask(void) slist[3] = ENDLIST; slist[4] = ENDLIST; - for (i = 0; i < NR_OF_SEMA_RUNS; i++) - task_sem_take_wait(SEM1); - for (i = 0; i < NR_OF_SEMA_RUNS; i++) - task_sem_take_wait_timeout(SEM1, SEMA_WAIT_TIME); + for (i = 0; i < NR_OF_SEMA_RUNS; i++) { + task_sem_take_wait(SEM1); + } + for (i = 0; i < NR_OF_SEMA_RUNS; i++) { + task_sem_take_wait_timeout(SEM1, SEMA_WAIT_TIME); + } - for (i = 0; i < NR_OF_SEMA_RUNS; i++) - task_sem_group_take_wait(slist); - for (i = 0; i < NR_OF_SEMA_RUNS; i++) - task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME); + for (i = 0; i < NR_OF_SEMA_RUNS; i++) { + task_sem_group_take_wait(slist); + } + for (i = 0; i < NR_OF_SEMA_RUNS; i++) { + task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME); + } slist[2] = SEM3; - for (i = 0; i < NR_OF_SEMA_RUNS; i++) - task_sem_group_take_wait(slist); - for (i = 0; i < NR_OF_SEMA_RUNS; i++) - task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME); + for (i = 0; i < NR_OF_SEMA_RUNS; i++) { + task_sem_group_take_wait(slist); + } + for (i = 0; i < NR_OF_SEMA_RUNS; i++) { + task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME); + } slist[3] = SEM4; - for (i = 0; i < NR_OF_SEMA_RUNS; i++) - task_sem_group_take_wait(slist); - for (i = 0; i < NR_OF_SEMA_RUNS; i++) - task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME); + for (i = 0; i < NR_OF_SEMA_RUNS; i++) { + task_sem_group_take_wait(slist); + } + for (i = 0; i < NR_OF_SEMA_RUNS; i++) { + task_sem_group_take_wait_timeout(slist, SEMA_WAIT_TIME); } +} #endif /* SEMA_BENCH */ diff --git a/samples/microkernel/benchmark/boot_time/src/boot_time.c b/samples/microkernel/benchmark/boot_time/src/boot_time.c index d3fb6606b..a0e4dcd2a 100644 --- a/samples/microkernel/benchmark/boot_time/src/boot_time.c +++ b/samples/microkernel/benchmark/boot_time/src/boot_time.c @@ -56,7 +56,7 @@ extern uint64_t __main_tsc; /* timestamp when main() begins executing */ extern uint64_t __idle_tsc; /* timestamp when CPU went idle */ void bootTimeTask(void) - { +{ uint64_t task_tsc; /* timestamp at beginning of first task */ uint64_t _start_us; /* being of __start timestamp in us */ uint64_t main_us; /* begin of main timestamp in us */ @@ -70,7 +70,7 @@ void bootTimeTask(void) task_tsc = _NanoTscRead(); #ifndef CONFIG_NANOKERNEL - /* Go to sleep for 1 tick in order to timestamp when IdleTask halts. */ + /* Go to sleep for 1 tick in order to timestamp when IdleTask halts. */ task_sleep(1); #endif /* ! CONFIG_NANOKERNEL */ @@ -84,30 +84,30 @@ void bootTimeTask(void) idle_us = s_idle_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ; #endif - /* Indicate start for sanity test suite */ + /* Indicate start for sanity test suite */ TC_START("Boot Time Measurement"); - /* Only print lower 32bit of time result */ + /* Only print lower 32bit of time result */ #ifdef CONFIG_NANOKERNEL TC_PRINT("NanoKernel Boot Result: Clock Frequency: %d MHz\n", - CONFIG_CPU_CLOCK_FREQ_MHZ); + CONFIG_CPU_CLOCK_FREQ_MHZ); #else /* CONFIG_MICROKERNEL */ TC_PRINT("MicroKernel Boot Result: Clock Frequency: %d MHz\n", - CONFIG_CPU_CLOCK_FREQ_MHZ); + CONFIG_CPU_CLOCK_FREQ_MHZ); #endif TC_PRINT("__start : %d cycles, %d us\n", - (uint32_t)(__start_tsc & 0xFFFFFFFFULL), - (uint32_t) (_start_us & 0xFFFFFFFFULL)); + (uint32_t)(__start_tsc & 0xFFFFFFFFULL), + (uint32_t) (_start_us & 0xFFFFFFFFULL)); TC_PRINT("_start->main(): %d cycles, %d us\n", - (uint32_t)(s_main_tsc & 0xFFFFFFFFULL), - (uint32_t) (main_us & 0xFFFFFFFFULL)); + (uint32_t)(s_main_tsc & 0xFFFFFFFFULL), + (uint32_t) (main_us & 0xFFFFFFFFULL)); TC_PRINT("_start->task : %d cycles, %d us\n", - (uint32_t)(s_task_tsc & 0xFFFFFFFFULL), - (uint32_t) (task_us & 0xFFFFFFFFULL)); + (uint32_t)(s_task_tsc & 0xFFFFFFFFULL), + (uint32_t) (task_us & 0xFFFFFFFFULL)); #ifndef CONFIG_NANOKERNEL /* CONFIG_MICROKERNEL */ TC_PRINT("_start->idle : %d cycles, %d us\n", - (uint32_t)(s_idle_tsc & 0xFFFFFFFFULL), - (uint32_t) (idle_us & 0xFFFFFFFFULL)); + (uint32_t)(s_idle_tsc & 0xFFFFFFFFULL), + (uint32_t) (idle_us & 0xFFFFFFFFULL)); #endif @@ -117,7 +117,7 @@ void bootTimeTask(void) TC_END_RESULT(TC_PASS); TC_END_REPORT(TC_PASS); - } +} #ifdef CONFIG_NANOKERNEL @@ -131,13 +131,13 @@ char fiberStack[512]; */ void main(void) - { - /* record timestamp for nanokernel's main() function */ +{ + /* record timestamp for nanokernel's main() function */ __main_tsc = _NanoTscRead(); - /* create bootTime fibers */ + /* create bootTime fibers */ task_fiber_start(fiberStack, 512, - (nano_fiber_entry_t) bootTimeTask, 0, 0, 6, 0); - } + (nano_fiber_entry_t) bootTimeTask, 0, 0, 6, 0); +} #endif /* CONFIG_NANOKERNEL */ diff --git a/samples/microkernel/benchmark/footprint/src/microkernel_footprint.c b/samples/microkernel/benchmark/footprint/src/microkernel_footprint.c index e2997a463..8a4204fda 100644 --- a/samples/microkernel/benchmark/footprint/src/microkernel_footprint.c +++ b/samples/microkernel/benchmark/footprint/src/microkernel_footprint.c @@ -84,27 +84,27 @@ NANO_CPU_INT_REGISTER(isrDummyIntStub, TEST_SOFT_INT, 0); /* pointer array ensures specified functions are linked into the image */ static pfunc func_array[] = { - /* event functions */ + /* event functions */ (pfunc)task_event_send, (pfunc)_task_event_recv, - /* mutex functions */ + /* mutex functions */ (pfunc)_task_mutex_lock, (pfunc)_task_mutex_unlock, - /* FIFO functions */ + /* FIFO functions */ (pfunc)_task_fifo_put, (pfunc)_task_fifo_get, (pfunc)_task_fifo_ioctl, - /* memory map functions */ + /* memory map functions */ (pfunc)task_mem_map_used_get, (pfunc)_task_mem_map_alloc, (pfunc)_task_mem_map_free, #ifdef TEST_max - /* task device interrupt functions */ + /* task device interrupt functions */ (pfunc)task_irq_alloc, (pfunc)_task_irq_test, (pfunc)task_irq_ack, (pfunc)task_irq_free, - /* semaphore functions */ + /* semaphore functions */ (pfunc)isr_sem_give, (pfunc)task_sem_give, (pfunc)task_sem_group_give, @@ -113,7 +113,7 @@ static pfunc func_array[] = { (pfunc)task_sem_group_reset, (pfunc)_task_sem_take, (pfunc)_task_sem_group_take, - /* pipe functions */ + /* pipe functions */ (pfunc)task_pipe_put, (pfunc)task_pipe_put_wait, (pfunc)task_pipe_put_wait_timeout, @@ -123,17 +123,17 @@ static pfunc func_array[] = { (pfunc)_task_pipe_put_async, (pfunc)_task_pipe_put, (pfunc)_task_pipe_get, - /* mailbox functions */ + /* mailbox functions */ (pfunc)_task_mbox_put, (pfunc)_task_mbox_get, (pfunc)_task_mbox_put_async, (pfunc)_task_mbox_data_get, (pfunc)_task_mbox_data_get_async_block, - /* memory pool functions */ + /* memory pool functions */ (pfunc)_task_mem_pool_alloc, (pfunc)task_mem_pool_free, (pfunc)task_mem_pool_defragment, - /* task functions */ + /* task functions */ (pfunc)_task_ioctl, (pfunc)_task_group_ioctl, (pfunc)task_abort_handler_set, @@ -142,7 +142,7 @@ static pfunc func_array[] = { (pfunc)task_sleep, (pfunc)task_yield, #endif /* TEST_max */ - }; +}; /******************************************************************************* * @@ -152,9 +152,9 @@ static pfunc func_array[] = { */ void dummyIsr(void *unused) - { +{ ARG_UNUSED(unused); - } +} #ifdef TEST_reg /******************************************************************************* @@ -169,13 +169,13 @@ void dummyIsr(void *unused) */ static void isrDummyIntStub(void *unused) - { +{ ARG_UNUSED(unused); isr_dummy(); CODE_UNREACHABLE; - } +} #endif /* TEST_reg */ /******************************************************************************* @@ -191,14 +191,14 @@ static void isrDummyIntStub(void *unused) */ void fgTaskEntry(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 */ - /* note: referencing "func_array" ensures it isn't optimized out */ + /* note: referencing "func_array" ensures it isn't optimized out */ #ifdef TEST_max printf((char *)MESSAGE, func_array); #else @@ -206,8 +206,8 @@ void fgTaskEntry(void) #endif /* TEST_max */ while (1) { - i++; - } + i++; } +} #endif /* TEST_min */ diff --git a/samples/microkernel/benchmark/footprint/src/test_asm_inline_gcc.h b/samples/microkernel/benchmark/footprint/src/test_asm_inline_gcc.h index 427e32051..83570103f 100644 --- a/samples/microkernel/benchmark/footprint/src/test_asm_inline_gcc.h +++ b/samples/microkernel/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/microkernel/benchmark/latency_measure/src/main.c b/samples/microkernel/benchmark/latency_measure/src/main.c index b7d995015..d3f59bf5e 100644 --- a/samples/microkernel/benchmark/latency_measure/src/main.c +++ b/samples/microkernel/benchmark/latency_measure/src/main.c @@ -54,7 +54,7 @@ int errorCount = 0; /* track number of errors */ */ void nanoTest(void) - { +{ PRINT_NANO_BANNER(); PRINT_TIME_BANNER(); @@ -72,7 +72,7 @@ void nanoTest(void) nanoIntLockUnlock(); printDashLine(); - } +} #ifdef CONFIG_NANOKERNEL /******************************************************************************* @@ -85,14 +85,14 @@ void nanoTest(void) */ void main(void) - { +{ bench_test_init(); nanoTest(); PRINT_END_BANNER(); TC_END_REPORT(errorCount); - } +} #else @@ -112,7 +112,7 @@ void microTaskSwitchYield(void); */ void microTest(void) - { +{ PRINT_MICRO_BANNER(); PRINT_TIME_BANNER(); @@ -130,7 +130,7 @@ void microTest(void) microTaskSwitchYield(); printDashLine(); - } +} /******************************************************************************* * @@ -142,7 +142,7 @@ void microTest(void) */ void microMain(void) - { +{ bench_test_init(); nanoTest(); @@ -150,5 +150,5 @@ void microMain(void) PRINT_END_BANNER(); TC_END_REPORT(errorCount); - } +} #endif /* CONFIG_NANOKERNEL */ diff --git a/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task.c b/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task.c index 83b83bf4e..4ebb8974c 100644 --- a/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task.c +++ b/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task.c @@ -58,12 +58,12 @@ static uint32_t timestamp; */ static void latencyTestIsr(void *unused) - { +{ ARG_UNUSED(unused); flagVar = 1; timestamp = TIME_STAMP_DELTA_GET(0); - } +} /******************************************************************************* * @@ -78,16 +78,17 @@ static void latencyTestIsr(void *unused) */ static void makeInt(void) - { +{ initSwInterrupt(latencyTestIsr); flagVar = 0; raiseIntFunc(); if (flagVar != 1) { - PRINT_FORMAT(" Flag variable has not changed. FAILED\n"); + PRINT_FORMAT(" Flag variable has not changed. FAILED\n"); } - else - timestamp = TIME_STAMP_DELTA_GET(timestamp); + else { + timestamp = TIME_STAMP_DELTA_GET(timestamp); } +} /******************************************************************************* * @@ -99,16 +100,16 @@ static void makeInt(void) */ int microIntToTask(void) - { +{ PRINT_FORMAT(" 1- Measure time to switch from ISR to back to" - " interrupted task"); + " interrupted task"); TICK_SYNCH(); makeInt(); if (flagVar == 1) { - PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); } return 0; - } +} #endif /* MICROKERNEL */ diff --git a/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task_evt.c b/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task_evt.c index f988c370c..f704fdaf7 100644 --- a/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task_evt.c +++ b/samples/microkernel/benchmark/latency_measure/src/micro_int_to_task_evt.c @@ -60,12 +60,12 @@ static uint32_t timestamp = 0; */ static void latencyTestIsr(void *unused) - { +{ ARG_UNUSED(unused); isr_event_send(EVENT0); timestamp = TIME_STAMP_DELTA_GET(0); - } +} /******************************************************************************* * @@ -81,12 +81,12 @@ static void latencyTestIsr(void *unused) */ void microInt(void) - { +{ task_sem_take_wait(INTSEMA); setSwInterrupt(latencyTestIsr); raiseIntFunc(); task_suspend(task_id_get()); - } +} /******************************************************************************* * @@ -98,16 +98,16 @@ void microInt(void) */ int microIntToTaskEvt(void) - { +{ PRINT_FORMAT(" 2- Measure time from ISR to executing a different task" - " (rescheduled)"); + " (rescheduled)"); TICK_SYNCH(); task_sem_give(INTSEMA); task_event_recv_wait(EVENT0); timestamp = TIME_STAMP_DELTA_GET(timestamp); PRINT_FORMAT(" switch time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); return 0; - } +} #endif /* CONFIG_MICROKERNEL */ diff --git a/samples/microkernel/benchmark/latency_measure/src/micro_sema_lock_release.c b/samples/microkernel/benchmark/latency_measure/src/micro_sema_lock_release.c index 06a572632..18f9ba51d 100644 --- a/samples/microkernel/benchmark/latency_measure/src/micro_sema_lock_release.c +++ b/samples/microkernel/benchmark/latency_measure/src/micro_sema_lock_release.c @@ -66,44 +66,44 @@ static uint32_t timestamp; */ int microSemaLockUnlock(void) - { +{ int i; PRINT_FORMAT(" 3- Measure average time to signal a sema then test" - " that sema"); + " that sema"); bench_test_start(); timestamp = TIME_STAMP_DELTA_GET(0); for (i = SEMASTART; i <= SEMAEND; i++) { - task_sem_give(i); + task_sem_give(i); } timestamp = TIME_STAMP_DELTA_GET(timestamp); if (bench_test_end() == 0) { - PRINT_FORMAT(" Average semaphore signal time %lu tcs = %lu nsec", - timestamp / N_TEST_SEMA, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA)); + PRINT_FORMAT(" Average semaphore signal time %lu tcs = %lu nsec", + timestamp / N_TEST_SEMA, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA)); } else { - errorCount++; - PRINT_OVERFLOW_ERROR(); + errorCount++; + PRINT_OVERFLOW_ERROR(); } bench_test_start(); timestamp = TIME_STAMP_DELTA_GET(0); for (i = SEMASTART; i <= SEMAEND; i++) { - task_sem_take_wait(i); + task_sem_take_wait(i); } timestamp = TIME_STAMP_DELTA_GET(timestamp); if (bench_test_end() == 0) { - PRINT_FORMAT(" Average semaphore test time %lu tcs = %lu nsec", - timestamp / N_TEST_SEMA, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA)); + PRINT_FORMAT(" Average semaphore test time %lu tcs = %lu nsec", + timestamp / N_TEST_SEMA, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_SEMA)); } else { - errorCount++; - PRINT_OVERFLOW_ERROR(); + errorCount++; + PRINT_OVERFLOW_ERROR(); } return 0; - } +} /******************************************************************************* * @@ -118,28 +118,28 @@ int microSemaLockUnlock(void) */ int microMutexLockUnlock(void) - { +{ int i; PRINT_FORMAT(" 4- Measure average time to lock a mutex then" - " unlock that mutex"); + " unlock that mutex"); timestamp = TIME_STAMP_DELTA_GET(0); for (i = 0; i < N_TEST_MUTEX; i++) { - task_mutex_lock_wait(TEST_MUTEX); + task_mutex_lock_wait(TEST_MUTEX); } timestamp = TIME_STAMP_DELTA_GET(timestamp); PRINT_FORMAT(" Average time to lock the mutex %lu tcs = %lu nsec", - timestamp / N_TEST_MUTEX, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX)); + timestamp / N_TEST_MUTEX, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX)); timestamp = TIME_STAMP_DELTA_GET(0); for (i = 0; i <= N_TEST_MUTEX; i++) { - task_mutex_unlock(TEST_MUTEX); + task_mutex_unlock(TEST_MUTEX); } timestamp = TIME_STAMP_DELTA_GET(timestamp); PRINT_FORMAT(" Average time to unlock the mutex %lu tcs = %lu nsec", - timestamp / N_TEST_MUTEX, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX)); + timestamp / N_TEST_MUTEX, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, N_TEST_MUTEX)); return 0; - } +} #endif /* CONFIG_MICROKERNEL */ diff --git a/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c b/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c index 15ee63d3b..88f37504b 100644 --- a/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c +++ b/samples/microkernel/benchmark/latency_measure/src/micro_task_switch_yield.c @@ -62,12 +62,12 @@ static uint32_t helper_task_iterations = 0; */ void yieldingTask(void) - { +{ while (helper_task_iterations < NB_OF_YIELD) { - task_yield(); - helper_task_iterations++; - } + task_yield(); + helper_task_iterations++; } +} /******************************************************************************* * @@ -79,60 +79,60 @@ void yieldingTask(void) */ void microTaskSwitchYield(void) - { +{ uint32_t iterations = 0; int32_t delta; uint32_t timestamp; PRINT_FORMAT(" 5- Measure average context switch time between tasks using" - " (task_yield)"); + " (task_yield)"); bench_test_start(); - /* launch helper task of the same priority than this routine */ + /* launch helper task of the same priority than this routine */ task_start(YIELDTASK); - /* get initial timestamp */ + /* get initial timestamp */ timestamp = TIME_STAMP_DELTA_GET(0); - /* loop until either helper or this routine reaches number of yields */ + /* loop until either helper or this routine reaches number of yields */ while (iterations < NB_OF_YIELD && helper_task_iterations < NB_OF_YIELD) { - task_yield(); - iterations++; + task_yield(); + iterations++; } - /* get the number of cycles it took to do the test */ + /* get the number of cycles it took to do the test */ timestamp = TIME_STAMP_DELTA_GET(timestamp); - /* Ensure both helper and this routine were context switching back & forth. - * For execution to reach the line below, either this routine or helper - * routine reached NB_OF_YIELD. The other loop must be at most one - * iteration away from reaching NB_OF_YIELD if execute was switching back - * and forth. - */ + /* Ensure both helper and this routine were context switching back & forth. + * For execution to reach the line below, either this routine or helper + * routine reached NB_OF_YIELD. The other loop must be at most one + * iteration away from reaching NB_OF_YIELD if execute was switching back + * and forth. + */ delta = iterations - helper_task_iterations; if (bench_test_end() < 0) { - errorCount++; - PRINT_OVERFLOW_ERROR(); + errorCount++; + PRINT_OVERFLOW_ERROR(); } else if (abs(delta) > 1) { - /* expecting even alternating context switch, seems one routine - * called yield without the other having chance to execute - */ - errorCount++; - PRINT_FORMAT(" Error, iteration:%lu, helper iteration:%lu", - iterations, helper_task_iterations); + /* expecting even alternating context switch, seems one routine + * called yield without the other having chance to execute + */ + errorCount++; + PRINT_FORMAT(" Error, iteration:%lu, helper iteration:%lu", + iterations, helper_task_iterations); } else { - /* task_yield is called (iterations + helper_task_iterations) - * times in total. - */ - PRINT_FORMAT(" Average task context switch using " - "yield %lu tcs = %lu nsec", - timestamp / (iterations + helper_task_iterations), - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, - (iterations + helper_task_iterations))); - } + /* task_yield is called (iterations + helper_task_iterations) + * times in total. + */ + PRINT_FORMAT(" Average task context switch using " + "yield %lu tcs = %lu nsec", + timestamp / (iterations + helper_task_iterations), + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, + (iterations + helper_task_iterations))); } +} #endif diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_ctx_switch.c b/samples/microkernel/benchmark/latency_measure/src/nano_ctx_switch.c index 736d6a05d..9e349e877 100644 --- a/samples/microkernel/benchmark/latency_measure/src/nano_ctx_switch.c +++ b/samples/microkernel/benchmark/latency_measure/src/nano_ctx_switch.c @@ -77,16 +77,16 @@ static volatile int ctxSwitchBalancer = 0; */ static void fiberOne(void) - { +{ nano_fiber_sem_take_wait(&syncSema); timestamp = TIME_STAMP_DELTA_GET(0); while (ctxSwitchCounter < NCTXSWITCH) { - fiber_yield(); - ctxSwitchCounter++; - ctxSwitchBalancer--; + fiber_yield(); + ctxSwitchCounter++; + ctxSwitchBalancer--; } timestamp = TIME_STAMP_DELTA_GET(timestamp); - } +} /******************************************************************************* * @@ -101,14 +101,14 @@ static void fiberOne(void) */ static void fiberTwo(void) - { +{ nano_fiber_sem_give(&syncSema); while (ctxSwitchCounter < NCTXSWITCH) { - fiber_yield(); - ctxSwitchCounter++; - ctxSwitchBalancer++; - } + fiber_yield(); + ctxSwitchCounter++; + ctxSwitchBalancer++; } +} /******************************************************************************* * @@ -120,7 +120,7 @@ static void fiberTwo(void) */ int nanoCtxSwitch(void) - { +{ PRINT_FORMAT(" 4- Measure average context switch time between fibers"); nano_sem_init(&syncSema); ctxSwitchCounter = 0; @@ -128,19 +128,20 @@ int nanoCtxSwitch(void) bench_test_start(); task_fiber_start(&fiberOneStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberOne, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberOne, 0, 0, 6, 0); task_fiber_start(&fiberTwoStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberTwo, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberTwo, 0, 0, 6, 0); if (ctxSwitchBalancer > 3 || ctxSwitchBalancer < -3) { - PRINT_FORMAT(" Balance is %d. FAILED", ctxSwitchBalancer); + PRINT_FORMAT(" Balance is %d. FAILED", ctxSwitchBalancer); } else if (bench_test_end() != 0) { - errorCount++; - PRINT_OVERFLOW_ERROR(); + errorCount++; + PRINT_OVERFLOW_ERROR(); } - else - PRINT_FORMAT(" Average context switch time is %lu tcs = %lu nsec", - timestamp / ctxSwitchCounter, - SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, ctxSwitchCounter)); - return 0; + else { + PRINT_FORMAT(" Average context switch time is %lu tcs = %lu nsec", + timestamp / ctxSwitchCounter, + SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, ctxSwitchCounter)); } + return 0; +} diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_int.c b/samples/microkernel/benchmark/latency_measure/src/nano_int.c index ff0c7158a..2d6322784 100644 --- a/samples/microkernel/benchmark/latency_measure/src/nano_int.c +++ b/samples/microkernel/benchmark/latency_measure/src/nano_int.c @@ -60,11 +60,11 @@ static uint32_t timestamp; */ static void latencyTestIsr(void *unused) - { +{ ARG_UNUSED(unused); timestamp = TIME_STAMP_DELTA_GET(timestamp); - } +} /******************************************************************************* * @@ -79,11 +79,11 @@ static void latencyTestIsr(void *unused) */ static void fiberInt(void) - { +{ initSwInterrupt(latencyTestIsr); timestamp = TIME_STAMP_DELTA_GET(0); raiseIntFunc(); - } +} /******************************************************************************* * @@ -95,12 +95,12 @@ static void fiberInt(void) */ int nanoIntLatency(void) - { +{ PRINT_FORMAT(" 1- Measure time to switch from fiber to ISR execution"); TICK_SYNCH(); task_fiber_start(&fiberStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); return 0; - } +} diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_int_lock_unlock.c b/samples/microkernel/benchmark/latency_measure/src/nano_int_lock_unlock.c index bc417bf4f..0ad1860a8 100644 --- a/samples/microkernel/benchmark/latency_measure/src/nano_int_lock_unlock.c +++ b/samples/microkernel/benchmark/latency_measure/src/nano_int_lock_unlock.c @@ -59,48 +59,48 @@ static uint32_t timestamp = 0; */ int nanoIntLockUnlock(void) - { +{ int i; unsigned int mask; PRINT_FORMAT(" 5- Measure average time to lock then unlock interrupts"); PRINT_FORMAT(" 5.1- When each lock and unlock is executed as a function" - " call"); + " call"); bench_test_start(); timestamp = TIME_STAMP_DELTA_GET(0); for (i = 0; i < NTESTS; i++) { - mask = irq_lock(); - irq_unlock(mask); + mask = irq_lock(); + irq_unlock(mask); } timestamp = TIME_STAMP_DELTA_GET(timestamp); if (bench_test_end() == 0) { - PRINT_FORMAT(" Average time for lock then unlock " - "is %lu tcs = %lu nsec", - timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS)); + PRINT_FORMAT(" Average time for lock then unlock " + "is %lu tcs = %lu nsec", + timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS)); } else { - errorCount++; - PRINT_OVERFLOW_ERROR(); + errorCount++; + PRINT_OVERFLOW_ERROR(); } PRINT_FORMAT(" "); PRINT_FORMAT(" 5.2- When each lock and unlock is executed as inline" - " function call"); + " function call"); bench_test_start(); timestamp = TIME_STAMP_DELTA_GET(0); for (i = 0; i < NTESTS; i++) { - mask = irq_lock_inline(); - irq_unlock_inline(mask); + mask = irq_lock_inline(); + irq_unlock_inline(mask); } timestamp = TIME_STAMP_DELTA_GET(timestamp); if (bench_test_end() == 0) { - PRINT_FORMAT(" Average time for lock then unlock " - "is %lu tcs = %lu nsec", - timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS)); + PRINT_FORMAT(" Average time for lock then unlock " + "is %lu tcs = %lu nsec", + timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG(timestamp, NTESTS)); } else { - errorCount++; - PRINT_OVERFLOW_ERROR(); + errorCount++; + PRINT_OVERFLOW_ERROR(); } return 0; - } +} diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber.c b/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber.c index 12f61784c..67dd7c9a3 100644 --- a/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber.c +++ b/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber.c @@ -62,12 +62,12 @@ static uint32_t timestamp; */ static void latencyTestIsr(void *unused) - { +{ ARG_UNUSED(unused); flagVar = 1; timestamp = TIME_STAMP_DELTA_GET(0); - } +} /******************************************************************************* * @@ -82,16 +82,17 @@ static void latencyTestIsr(void *unused) */ static void fiberInt(void) - { +{ setSwInterrupt(latencyTestIsr); flagVar = 0; raiseIntFunc(); if (flagVar != 1) { - PRINT_FORMAT(" Flag variable has not changed. FAILED"); + PRINT_FORMAT(" Flag variable has not changed. FAILED"); } - else - timestamp = TIME_STAMP_DELTA_GET(timestamp); + else { + timestamp = TIME_STAMP_DELTA_GET(timestamp); } +} /******************************************************************************* * @@ -103,15 +104,15 @@ static void fiberInt(void) */ int nanoIntToFiber(void) - { +{ PRINT_FORMAT(" 2- Measure time to switch from ISR back to interrupted" - " fiber"); + " fiber"); TICK_SYNCH(); task_fiber_start(&fiberStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); if (flagVar == 1) { - PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); } return 0; - } +} diff --git a/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber_sem.c b/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber_sem.c index 8aecaa4d9..c0d59cf1d 100644 --- a/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber_sem.c +++ b/samples/microkernel/benchmark/latency_measure/src/nano_int_to_fiber_sem.c @@ -73,12 +73,12 @@ static uint32_t timestamp = 0; */ static void latencyTestIsr(void *unused) - { +{ ARG_UNUSED(unused); nano_isr_sem_give(&testSema); timestamp = TIME_STAMP_DELTA_GET(0); - } +} /******************************************************************************* * @@ -93,11 +93,11 @@ static void latencyTestIsr(void *unused) */ static void fiberInt(void) - { +{ setSwInterrupt(latencyTestIsr); raiseIntFunc(); fiber_yield(); - } +} /******************************************************************************* * @@ -112,10 +112,10 @@ static void fiberInt(void) */ static void fiberWaiter(void) - { +{ nano_fiber_sem_take_wait(&testSema); timestamp = TIME_STAMP_DELTA_GET(timestamp); - } +} /******************************************************************************* * @@ -127,18 +127,18 @@ static void fiberWaiter(void) */ int nanoIntToFiberSem(void) - { +{ PRINT_FORMAT(" 3- Measure time from ISR to executing a different fiber" - " (rescheduled)"); + " (rescheduled)"); nano_sem_init(&testSema); TICK_SYNCH(); task_fiber_start(&waiterStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberWaiter, 0, 0, 5, 0); + (nano_fiber_entry_t) fiberWaiter, 0, 0, 5, 0); task_fiber_start(&intStack[0], STACKSIZE, - (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); + (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); PRINT_FORMAT(" switching time is %lu tcs = %lu nsec", - timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); + timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); return 0; - } +} diff --git a/samples/microkernel/benchmark/latency_measure/src/timestamp.h b/samples/microkernel/benchmark/latency_measure/src/timestamp.h index 51b553a28..d43ba703f 100644 --- a/samples/microkernel/benchmark/latency_measure/src/timestamp.h +++ b/samples/microkernel/benchmark/latency_measure/src/timestamp.h @@ -85,29 +85,30 @@ typedef int64_t TICK_TYPE; extern uint32_t tm_off; static inline uint32_t TIME_STAMP_DELTA_GET(uint32_t ts) - { +{ uint32_t t; - /* serialize so OS_GET_TIME() is not reordered */ + /* serialize so OS_GET_TIME() is not reordered */ timestamp_serialize(); t = OS_GET_TIME(); uint32_t res = (t >= ts)? (t - ts): (ULONG_MAX - ts + t); - if (ts > 0) - res -= tm_off; - return res; + if (ts > 0) { + res -= tm_off; } + return res; +} /* * Routine initializes the benchmark timing measurement * The function sets up the global variable tm_off */ static inline void bench_test_init(void) - { +{ uint32_t t = OS_GET_TIME(); tm_off = OS_GET_TIME() - t; - } +} #if defined(CONFIG_MICROKERNEL) && defined(KERNEL) @@ -127,23 +128,23 @@ static TICK_TYPE tCheck; * Functions modify the tCheck global variable. */ static inline void bench_test_start(void) - { +{ tCheck = 0; - /* before reading time we synchronize to the start of the timer tick */ + /* before reading time we synchronize to the start of the timer tick */ TICK_SYNCH(); tCheck = TICK_GET(&tCheck); - } +} /* returns 0 if the number of ticks is valid and -1 if not */ static inline int bench_test_end(void) - { +{ tCheck = TICK_GET(&tCheck); - if (tCheck > BENCH_MAX_TICKS) - return -1; - else - return 0; + if (tCheck > BENCH_MAX_TICKS) { + return -1; } + return 0; +} /* * Returns -1 if number of ticks cause high precision timer counter @@ -152,12 +153,12 @@ static inline int bench_test_end(void) * results or is it completely invalid */ static inline int high_timer_overflow(void) - { - if (tCheck >= (UINT_MAX / sys_clock_hw_cycles_per_tick)) - return -1; - else - return 0; +{ + if (tCheck >= (UINT_MAX / sys_clock_hw_cycles_per_tick)) { + return -1; } + return 0; +} #endif /* CONFIG_NANOKERNEL || CONFIG_MICROKERNEL */ #endif /* _TIMESTAMP_H_ */ diff --git a/samples/microkernel/benchmark/latency_measure/src/utils.c b/samples/microkernel/benchmark/latency_measure/src/utils.c index 2a9df77ac..920ae2aa6 100644 --- a/samples/microkernel/benchmark/latency_measure/src/utils.c +++ b/samples/microkernel/benchmark/latency_measure/src/utils.c @@ -73,13 +73,13 @@ char tmpString[TMP_STRING_SIZE]; */ int initSwInterrupt(ptestIsr pIsrHdlr) - { +{ vector = irq_connect(NANO_SOFT_IRQ, IRQ_PRIORITY, pIsrHdlr, (void *) 0, isrLatencyHandlerStub); pcurrIsrFunc = pIsrHdlr; return vector; - } +} /******************************************************************************* * @@ -95,10 +95,10 @@ int initSwInterrupt(ptestIsr pIsrHdlr) */ void setSwInterrupt(ptestIsr pIsrHdlr) - { +{ irq_handler_set(vector, pcurrIsrFunc, pIsrHdlr, (void *)0); pcurrIsrFunc = pIsrHdlr; - } +} /******************************************************************************* * @@ -114,6 +114,6 @@ void setSwInterrupt(ptestIsr pIsrHdlr) * \NOMANUAL */ void raiseIntFunc(void) - { +{ raiseInt(vector); - } +} diff --git a/samples/microkernel/benchmark/latency_measure/src/utils.h b/samples/microkernel/benchmark/latency_measure/src/utils.h index 7f5cfd62e..6703c12fe 100644 --- a/samples/microkernel/benchmark/latency_measure/src/utils.h +++ b/samples/microkernel/benchmark/latency_measure/src/utils.h @@ -51,13 +51,11 @@ extern int errorCount; #define PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__) #define PRINTF(fmt, ...) printf(fmt, ##__VA_ARGS__) -#define PRINT_FORMAT(fmt, ...) \ - do \ - { \ +#define PRINT_FORMAT(fmt, ...) \ + do { \ snprintf(tmpString, TMP_STRING_SIZE, fmt, ##__VA_ARGS__); \ PRINTF("|%-77s|\n", tmpString); \ - } \ - while (0) + } while (0) /******************************************************************************* * @@ -69,33 +67,34 @@ extern int errorCount; */ static inline void printDashLine(void) - { +{ PRINTF("|-----------------------------------------------------------------" - "------------|\n"); - } + "------------|\n"); +} -#define PRINT_END_BANNER() \ +#define PRINT_END_BANNER() \ PRINTF("| E N D "\ - " |\n"); \ + " |\n"); \ printDashLine(); -#define PRINT_NANO_BANNER() \ +#define PRINT_NANO_BANNER() \ printDashLine(); \ PRINTF("| VxMicro Nanokernel Latency Benchmark "\ - " |\n"); \ + " |\n"); \ printDashLine(); -#define PRINT_MICRO_BANNER() \ +#define PRINT_MICRO_BANNER() \ printDashLine(); \ PRINTF("| VxMicro Microkernel Latency Benchmark "\ - " |\n"); \ + " |\n"); \ printDashLine(); -#define PRINT_TIME_BANNER() \ - PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", SYS_CLOCK_HW_CYCLES_TO_NS(1));\ +#define PRINT_TIME_BANNER() \ + PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", \ + SYS_CLOCK_HW_CYCLES_TO_NS(1)); \ printDashLine(); -#define PRINT_OVERFLOW_ERROR() \ +#define PRINT_OVERFLOW_ERROR() \ PRINT_FORMAT(" Error: tick occured") #else |