Fix checkpatch issue - WARNING:LEADING_SPACE

Changing each four whitespaces for one tab at the beginning of the
lines that the checkpatch script marks as having the warning LEADING_SPACE.

Change accomplished with the following script:

	#!/bin/bash
	checkpatch_script="$VXMICRO_BASE/scripts/checkpatch.pl --mailback --no-tree -f --emacs --summary-file --show-types --ignore BRACES,PRINTK_WITHOUT_KERN_LEVEL,SPLIT_STRING --max-line-length=100 "
	for file in $(find ./ -name "*.[ch]" ! -path "./scripts/*" ! -path "./host/src/wrsconfig/*");
	do
		for line in $(eval $checkpatch_script $file | grep "WARNING:LEADING_SPACE" | cut -d":" -f2)
		do
			sed -i -r -e ''$line' {s/^    /\t/; s/^([\t]*)    /\1\t/g}' $file;
		done;
	done;

Change-Id: I999e59710f52098ad3ec336b99c05356215cc671
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
This commit is contained in:
Yonattan Louise 2015-05-11 10:16:29 -05:00 committed by Anas Nashif
commit c41d243602
43 changed files with 1179 additions and 1179 deletions

View file

@ -65,8 +65,8 @@ extern int sys_clock_hw_cycles_per_tick;
/* SYS_CLOCK_HW_CYCLES_TO_NS64 converts CPU clock cycles to nanoseconds */ /* SYS_CLOCK_HW_CYCLES_TO_NS64 converts CPU clock cycles to nanoseconds */
#define SYS_CLOCK_HW_CYCLES_TO_NS64(X) \ #define SYS_CLOCK_HW_CYCLES_TO_NS64(X) \
(((uint64_t)(X) * sys_clock_us_per_tick * NSEC_PER_USEC) / \ (((uint64_t)(X) * sys_clock_us_per_tick * NSEC_PER_USEC) / \
sys_clock_hw_cycles_per_tick) sys_clock_hw_cycles_per_tick)
/* /*
* SYS_CLOCK_HW_CYCLES_TO_NS_AVG converts CPU clock cycles to nanoseconds * SYS_CLOCK_HW_CYCLES_TO_NS_AVG converts CPU clock cycles to nanoseconds

View file

@ -42,16 +42,16 @@ extern "C" {
#include <microkernel/mail_api_export.h> #include <microkernel/mail_api_export.h>
extern int _task_mbox_put(kmbox_t mbox, extern int _task_mbox_put(kmbox_t mbox,
kpriority_t prio, kpriority_t prio,
struct k_msg *M, struct k_msg *M,
int32_t time); int32_t time);
extern int _task_mbox_get(kmbox_t mbox, struct k_msg *M, int32_t time); extern int _task_mbox_get(kmbox_t mbox, struct k_msg *M, int32_t time);
extern void _task_mbox_put_async(kmbox_t mbox, extern void _task_mbox_put_async(kmbox_t mbox,
kpriority_t prio, kpriority_t prio,
struct k_msg *M, struct k_msg *M,
ksem_t sem); ksem_t sem);
extern void _task_mbox_data_get(struct k_msg *M); extern void _task_mbox_data_get(struct k_msg *M);
@ -63,13 +63,13 @@ extern int _task_mbox_data_get_async_block(struct k_msg *M,
#define task_mbox_put_async(b, p, m, s) _task_mbox_put_async(b, p, m, s) #define task_mbox_put_async(b, p, m, s) _task_mbox_put_async(b, p, m, s)
#define task_mbox_data_get(m) _task_mbox_data_get(m) #define task_mbox_data_get(m) _task_mbox_data_get(m)
#define task_mbox_data_get_async_block(m, b, p) \ #define task_mbox_data_get_async_block(m, b, p) \
_task_mbox_data_get_async_block(m, b, p, TICKS_NONE) _task_mbox_data_get_async_block(m, b, p, TICKS_NONE)
#define task_mbox_data_get_async_block_wait(m, b, p) \ #define task_mbox_data_get_async_block_wait(m, b, p) \
_task_mbox_data_get_async_block(m, b, p, TICKS_UNLIMITED) _task_mbox_data_get_async_block(m, b, p, TICKS_UNLIMITED)
#ifndef CONFIG_TICKLESS_KERNEL #ifndef CONFIG_TICKLESS_KERNEL
#define task_mbox_data_get_async_block_wait_timeout(m, b, p, t) \ #define task_mbox_data_get_async_block_wait_timeout(m, b, p, t) \
_task_mbox_data_get_async_block(m, b, p, t) _task_mbox_data_get_async_block(m, b, p, t)
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -98,8 +98,8 @@ extern void task_timer_start(ktimer_t timer,
int32_t period, int32_t period,
ksem_t sema); ksem_t sema);
extern void task_timer_restart(ktimer_t timer, extern void task_timer_restart(ktimer_t timer,
int32_t duration, int32_t duration,
int32_t period); int32_t period);
extern void task_timer_stop(ktimer_t timer); extern void task_timer_stop(ktimer_t timer);
extern int64_t task_tick_delta(int64_t *reftime); extern int64_t task_tick_delta(int64_t *reftime);
static inline int32_t task_tick_delta_32(int64_t *reftime) static inline int32_t task_tick_delta_32(int64_t *reftime)

View file

@ -66,14 +66,14 @@ int example_handler (int event);
*/ */
void event_test (void) void event_test (void)
{ {
int nReturn; int nReturn;
int nCounter; int nCounter;
uint32_t et; /* elapsed time */ uint32_t et; /* elapsed time */
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
nReturn = task_event_send (TEST_EVENT); nReturn = task_event_send (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != RC_OK) {
@ -82,14 +82,14 @@ void event_test (void)
} }
#endif /* EVENT_CHECK */ #endif /* EVENT_CHECK */
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "Signal enabled event", 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 (); et = BENCH_START ();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
nReturn = task_event_send (TEST_EVENT); nReturn = task_event_send (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != RC_OK) {
@ -107,14 +107,14 @@ void event_test (void)
} }
#endif /* EVENT_CHECK */ #endif /* EVENT_CHECK */
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "Signal event & Test event", 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 (); et = BENCH_START ();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
nReturn = task_event_send (TEST_EVENT); nReturn = task_event_send (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != RC_OK) {
@ -130,22 +130,22 @@ void event_test (void)
} }
#endif /* EVENT_CHECK */ #endif /* EVENT_CHECK */
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "Signal event & TestW event", 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" PRINT_STRING ("| Signal event with installed handler"
" |\n", output_file); " |\n", output_file);
nReturn = task_event_set_handler (TEST_EVENT, example_handler); nReturn = task_event_set_handler (TEST_EVENT, example_handler);
if (nReturn != RC_OK) { if (nReturn != RC_OK) {
PRINT_F (output_file, "-------- Error installing event handler.\n"); PRINT_F (output_file, "-------- Error installing event handler.\n");
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
return; /* error */ return; /* error */
} }
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) { for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
nReturn = task_event_send (TEST_EVENT); nReturn = task_event_send (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) { if (nReturn != RC_OK) {
@ -162,19 +162,19 @@ void event_test (void)
nEventValue = 0; nEventValue = 0;
} }
nReturn = task_event_set_handler (TEST_EVENT, NULL); nReturn = task_event_set_handler (TEST_EVENT, NULL);
if (nReturn != RC_OK) { if (nReturn != RC_OK) {
PRINT_F (output_file, "Error removing event handler.\n"); PRINT_F (output_file, "Error removing event handler.\n");
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
return; /* error */ return; /* error */
} }
PRINT_STRING ("| Handler responds OK" PRINT_STRING ("| Handler responds OK"
" |\n", " |\n",
output_file); output_file);
return; /* success */ return; /* success */
} }
/******************************************************************************* /*******************************************************************************
@ -190,10 +190,10 @@ void event_test (void)
*/ */
int example_handler (int event) int example_handler (int event)
{ {
nEventValue = event + 1; nEventValue = event + 1;
return 1; return 1;
} }
#endif /* EVENT_BENCH */ #endif /* EVENT_BENCH */

View file

@ -44,73 +44,73 @@
*/ */
void queue_test (void) void queue_test (void)
{ {
uint32_t et; /* elapsed time */ uint32_t et; /* elapsed time */
int i; int i;
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { 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); et = TIME_STAMP_DELTA_GET (et);
PRINT_F (output_file, FORMAT, "enqueue 1 byte msg in FIFO", 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { 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); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "dequeue 1 byte msg in FIFO", 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { 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); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "enqueue 4 bytes msg in FIFO", 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { 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); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "dequeue 4 bytes msg in FIFO", 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); task_sem_give (STARTRCV);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { 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); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, PRINT_F (output_file, FORMAT,
"enqueue 1 byte msg in FIFO to a waiting higher priority task", "enqueue 1 byte msg in FIFO to a waiting higher priority task",
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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) { 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); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, PRINT_F (output_file, FORMAT,
"enqueue 4 bytes in FIFO to a waiting higher priority task", "enqueue 4 bytes in FIFO to a waiting higher priority task",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
} }
#endif /* FIFO_BENCH */ #endif /* FIFO_BENCH */

View file

@ -46,16 +46,16 @@
*/ */
void dequtask (void) void dequtask (void)
{ {
int x, i; int x, i;
for (i = 0; i < NR_OF_FIFO_RUNS; 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++) { for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
task_fifo_get_wait (DEMOQX4, &x); task_fifo_get_wait (DEMOQX4, &x);
} }
} }
#endif /* FIFO_BENCH */ #endif /* FIFO_BENCH */

View file

@ -38,42 +38,42 @@ static struct k_msg Message;
#ifdef FLOAT #ifdef FLOAT
#define PRINT_HEADER() \ #define PRINT_HEADER() \
PRINT_STRING \ PRINT_STRING \
("| size(B) | time/packet (usec) | MB/sec" \ ("| size(B) | time/packet (usec) | MB/sec" \
" |\n", output_file); " |\n", output_file);
#define PRINT_ONE_RESULT() \ #define PRINT_ONE_RESULT() \
PRINT_F (output_file, "|%11lu|%32.3f|%32f|\n", putsize, puttime / 1000.0, \ PRINT_F (output_file, "|%11lu|%32.3f|%32f|\n", putsize, puttime / 1000.0, \
(1000.0 * putsize) / puttime) (1000.0 * putsize) / puttime)
#define PRINT_OVERHEAD() \ #define PRINT_OVERHEAD() \
PRINT_F (output_file, \ PRINT_F (output_file, \
"| message overhead: %10.3f usec/packet "\ "| message overhead: %10.3f usec/packet "\
" |\n", EmptyMsgPutTime / 1000.0) " |\n", EmptyMsgPutTime / 1000.0)
#define PRINT_XFER_RATE() \ #define PRINT_XFER_RATE() \
double NettoTransferRate; \ double NettoTransferRate; \
NettoTransferRate = 1000.0 * (putsize >> 1) / (puttime - EmptyMsgPutTime);\ NettoTransferRate = 1000.0 * (putsize >> 1) / (puttime - EmptyMsgPutTime);\
PRINT_F (output_file, \ PRINT_F (output_file, \
"| raw transfer rate: %10.3f MB/sec (without" \ "| raw transfer rate: %10.3f MB/sec (without" \
" overhead) |\n", NettoTransferRate) " overhead) |\n", NettoTransferRate)
#else #else
#define PRINT_HEADER() \ #define PRINT_HEADER() \
PRINT_STRING \ PRINT_STRING \
("| size(B) | time/packet (nsec) | KB/sec" \ ("| size(B) | time/packet (nsec) | KB/sec" \
" |\n", output_file); " |\n", output_file);
#define PRINT_ONE_RESULT() \ #define PRINT_ONE_RESULT() \
PRINT_F (output_file, "|%11lu|%32lu|%32lu|\n", putsize, puttime, \ PRINT_F (output_file, "|%11lu|%32lu|%32lu|\n", putsize, puttime, \
(uint32_t)((1000000 * (uint64_t)putsize) / puttime)) (uint32_t)((1000000 * (uint64_t)putsize) / puttime))
#define PRINT_OVERHEAD() \ #define PRINT_OVERHEAD() \
PRINT_F (output_file, \ PRINT_F (output_file, \
"| message overhead: %10u nsec/packet "\ "| message overhead: %10u nsec/packet "\
" |\n", EmptyMsgPutTime) " |\n", EmptyMsgPutTime)
#define PRINT_XFER_RATE() \ #define PRINT_XFER_RATE() \
PRINT_F (output_file, "| raw transfer rate: %10lu KB/sec (without" \ PRINT_F (output_file, "| raw transfer rate: %10lu KB/sec (without" \
" overhead) |\n", \ " overhead) |\n", \
(uint32_t)(1000000 * (uint64_t)(putsize >> 1) \ (uint32_t)(1000000 * (uint64_t)(putsize >> 1) \
/ (puttime - EmptyMsgPutTime))) / (puttime - EmptyMsgPutTime)))
@ -100,45 +100,45 @@ void mailbox_put (uint32_t size, int count, uint32_t *time);
*/ */
void mailbox_test (void) void mailbox_test (void)
{ {
uint32_t putsize; uint32_t putsize;
uint32_t puttime; uint32_t puttime;
int putcount; int putcount;
unsigned int EmptyMsgPutTime; unsigned int EmptyMsgPutTime;
GetInfo getinfo; GetInfo getinfo;
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_STRING ("| " PRINT_STRING ("| "
"M A I L B O X M E A S U R E M E N T S" "M A I L B O X M E A S U R E M E N T S"
" |\n", output_file); " |\n", output_file);
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_STRING ("| Send mailbox message to waiting high " 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 " PRINT_F (output_file, "| repeat for %4d times and take the "
"average |\n", "average |\n",
NR_OF_MBOX_RUNS); NR_OF_MBOX_RUNS);
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_HEADER (); PRINT_HEADER ();
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
task_sem_reset (SEM0); task_sem_reset (SEM0);
task_sem_give (STARTRCV); task_sem_give (STARTRCV);
putcount = NR_OF_MBOX_RUNS; putcount = NR_OF_MBOX_RUNS;
putsize = 0; putsize = 0;
mailbox_put (putsize, putcount, &puttime); mailbox_put (putsize, putcount, &puttime);
task_fifo_get_wait (MB_COMM, &getinfo); /* waiting for ack */ task_fifo_get_wait (MB_COMM, &getinfo); /* waiting for ack */
PRINT_ONE_RESULT (); PRINT_ONE_RESULT ();
EmptyMsgPutTime = puttime; EmptyMsgPutTime = puttime;
for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) { for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) {
mailbox_put (putsize, putcount, &puttime); mailbox_put (putsize, putcount, &puttime);
task_fifo_get_wait (MB_COMM, &getinfo); /* waiting for ack */ task_fifo_get_wait (MB_COMM, &getinfo); /* waiting for ack */
PRINT_ONE_RESULT (); PRINT_ONE_RESULT ();
} }
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_OVERHEAD (); PRINT_OVERHEAD ();
PRINT_XFER_RATE (); PRINT_XFER_RATE ();
} }
/******************************************************************************* /*******************************************************************************
@ -151,27 +151,27 @@ void mailbox_test (void)
*/ */
void mailbox_put ( void mailbox_put (
uint32_t size, /* the size of the data chunk */ uint32_t size, /* the size of the data chunk */
int count, /* number of data chunks */ int count, /* number of data chunks */
uint32_t *time /* the total time */ uint32_t *time /* the total time */
) )
{ {
int i; int i;
unsigned int t; unsigned int t;
Message.rx_task = ANYTASK; Message.rx_task = ANYTASK;
Message.tx_data = data_bench; Message.tx_data = data_bench;
Message.size = size; Message.size = size;
/* first sync with the receiver */ /* first sync with the receiver */
task_sem_give (SEM0); task_sem_give (SEM0);
t = BENCH_START (); t = BENCH_START ();
for (i = 0; i < count; i++) { 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); t = TIME_STAMP_DELTA_GET (t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
check_result (); check_result ();
} }
#endif /* MAILBOX_BENCH */ #endif /* MAILBOX_BENCH */

View file

@ -56,29 +56,29 @@ int mailbox_get (kmbox_t mailbox,int size,int count,unsigned int* time);
*/ */
void mailrecvtask (void) void mailrecvtask (void)
{ {
int getsize; int getsize;
unsigned int gettime; unsigned int gettime;
int getcount; int getcount;
GetInfo getinfo; GetInfo getinfo;
getcount = NR_OF_MBOX_RUNS; getcount = NR_OF_MBOX_RUNS;
getsize = 0; getsize = 0;
mailbox_get (MAILB1, getsize, getcount, &gettime); mailbox_get (MAILB1, getsize, getcount, &gettime);
getinfo.time = gettime; getinfo.time = gettime;
getinfo.size = getsize; getinfo.size = getsize;
getinfo.count = getcount; getinfo.count = getcount;
task_fifo_put_wait (MB_COMM, &getinfo); /* acknowledge to master */ task_fifo_put_wait (MB_COMM, &getinfo); /* acknowledge to master */
for (getsize = 8; getsize <= MESSAGE_SIZE; getsize <<= 1) { for (getsize = 8; getsize <= MESSAGE_SIZE; getsize <<= 1) {
mailbox_get (MAILB1, getsize, getcount, &gettime); mailbox_get (MAILB1, getsize, getcount, &gettime);
getinfo.time = gettime; getinfo.time = gettime;
getinfo.size = getsize; getinfo.size = getsize;
getinfo.count = getcount; getinfo.count = getcount;
task_fifo_put_wait (MB_COMM, &getinfo); /* acknowledge to master */ task_fifo_put_wait (MB_COMM, &getinfo); /* acknowledge to master */
} }
} }
/******************************************************************************* /*******************************************************************************
@ -91,32 +91,32 @@ void mailrecvtask (void)
*/ */
int mailbox_get ( int mailbox_get (
kmbox_t mailbox, /* the mailbox to read data from */ kmbox_t mailbox, /* the mailbox to read data from */
int size, /* size of each data portion */ int size, /* size of each data portion */
int count, /* number of data portions */ int count, /* number of data portions */
unsigned int* time /* resulting time */ unsigned int* time /* resulting time */
) )
{ {
int i; int i;
unsigned int t; unsigned int t;
struct k_msg Message; struct k_msg Message;
Message.tx_task = ANYTASK; Message.tx_task = ANYTASK;
Message.rx_data = data_recv; Message.rx_data = data_recv;
Message.size = size; Message.size = size;
/* sync with the sender */ /* sync with the sender */
task_sem_take_wait (SEM0); task_sem_take_wait (SEM0);
t = BENCH_START (); t = BENCH_START ();
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
task_mbox_get_wait (mailbox, &Message); task_mbox_get_wait (mailbox, &Message);
} }
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
if (bench_test_end () < 0) if (bench_test_end () < 0)
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
return 0; return 0;
} }
#endif /* MAILBOX_BENCH */ #endif /* MAILBOX_BENCH */

View file

@ -49,8 +49,8 @@ kpipe_t TestPipes[] = {
PIPE_NOBUFF, PIPE_SMALLBUFF, PIPE_BIGBUFF}; PIPE_NOBUFF, PIPE_SMALLBUFF, PIPE_BIGBUFF};
#endif #endif
const char dashline[] = const char dashline[] =
"|--------------------------------------" "|--------------------------------------"
"---------------------------------------|\n"; "---------------------------------------|\n";
char sline[SLINE_LEN + 1]; char sline[SLINE_LEN + 1];
const char newline[] = "\n"; const char newline[] = "\n";
@ -73,7 +73,7 @@ uint32_t tm_off;
int kbhit (void) int kbhit (void)
{ {
return 0; return 0;
} }
@ -87,18 +87,18 @@ int kbhit (void)
*/ */
void init_output ( void init_output (
int *continuously, /* run test till the user presses the key */ int *continuously, /* run test till the user presses the key */
int *autorun /* expect user input */ int *autorun /* expect user input */
) )
{ {
ARG_UNUSED (continuously); ARG_UNUSED (continuously);
ARG_UNUSED (autorun); ARG_UNUSED (autorun);
/* /*
* send all printf and fprintf to console * send all printf and fprintf to console
*/ */
output_file = stdout; output_file = stdout;
} }
/******************************************************************************* /*******************************************************************************
* *
@ -110,8 +110,8 @@ void init_output (
*/ */
void output_close (void) void output_close (void)
{ {
} }
/* no need to wait for user key press when using console */ /* no need to wait for user key press when using console */
#define WAIT_FOR_USER() {} #define WAIT_FOR_USER() {}
@ -128,14 +128,14 @@ void output_close (void)
/* see config.h to select or to unselect*/ /* see config.h to select or to unselect*/
void BenchTask (void) void BenchTask (void)
{ {
int autorun = 0, continuously = 0; int autorun = 0, continuously = 0;
init_output (&continuously, &autorun); init_output (&continuously, &autorun);
bench_test_init (); bench_test_init ();
PRINT_STRING (newline, output_file); PRINT_STRING (newline, output_file);
do { do {
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_STRING ("| S I M P L E S E R V I C E " 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", "M E A S U R E M E N T S | nsec |\n",
@ -157,19 +157,19 @@ void BenchTask (void)
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_STRING ("VXMICRO PROJECT EXECUTION SUCCESSFUL\n",output_file); PRINT_STRING ("VXMICRO PROJECT EXECUTION SUCCESSFUL\n",output_file);
} }
while (continuously && !kbhit ()); while (continuously && !kbhit ());
WAIT_FOR_USER (); WAIT_FOR_USER ();
/* /*
* Make a 2 second delay. sys_clock_ticks_per_sec in this context is * Make a 2 second delay. sys_clock_ticks_per_sec in this context is
* a number of system times ticks in a second. * a number of system times ticks in a second.
*/ */
if (autorun) if (autorun)
task_sleep (2 * sys_clock_ticks_per_sec); task_sleep (2 * sys_clock_ticks_per_sec);
output_close (); output_close ();
} }
/******************************************************************************* /*******************************************************************************
@ -182,6 +182,6 @@ void BenchTask (void)
*/ */
void dummy_test (void) void dummy_test (void)
{ {
return; return;
} }

View file

@ -149,32 +149,32 @@ extern void event_test (void);
*/ */
#define PRINT_F(stream, fmt, ...) \ #define PRINT_F(stream, fmt, ...) \
{ \ { \
snprintf (sline, SLINE_LEN, fmt, ##__VA_ARGS__); \ snprintf (sline, SLINE_LEN, fmt, ##__VA_ARGS__); \
PRINT_STRING (sline, stream); \ PRINT_STRING (sline, stream); \
} }
#define PRINT_OVERFLOW_ERROR() \ #define PRINT_OVERFLOW_ERROR() \
PRINT_F (output_file, \ PRINT_F (output_file, \
__FILE__":%d Error: tick occured\n", __LINE__) __FILE__":%d Error: tick occured\n", __LINE__)
static inline uint32_t BENCH_START (void) static inline uint32_t BENCH_START (void)
{ {
uint32_t et; uint32_t et;
bench_test_start (); bench_test_start ();
et = TIME_STAMP_DELTA_GET (0); et = TIME_STAMP_DELTA_GET (0);
return et; return et;
} }
#define check_result() \ #define check_result() \
{ \ { \
if (bench_test_end () < 0) \ if (bench_test_end () < 0) \
{ \ { \
PRINT_OVERFLOW_ERROR (); \ PRINT_OVERFLOW_ERROR (); \
return; /* error */ \ return; /* error */ \
} \ } \
} }
#endif /* _MASTER_H */ #endif /* _MASTER_H */

View file

@ -46,22 +46,22 @@
*/ */
void memorymap_test (void) void memorymap_test (void)
{ {
uint32_t et; /* elapsed time */ uint32_t et; /* elapsed time */
int i; int i;
void* p; void* p;
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_MAP_RUNS; i++) { for (i = 0; i < NR_OF_MAP_RUNS; i++) {
task_mem_map_alloc_wait (MAP1, &p); task_mem_map_alloc_wait (MAP1, &p);
task_mem_map_free (MAP1, &p); task_mem_map_free (MAP1, &p);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "average alloc and dealloc memory page", 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 */ #endif /* MEMMAP_BENCH */

View file

@ -44,23 +44,23 @@
*/ */
void mempool_test (void) void mempool_test (void)
{ {
uint32_t et; /* elapsed time */ uint32_t et; /* elapsed time */
int i; int i;
struct k_block block; struct k_block block;
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_POOL_RUNS; i++) { for (i = 0; i < NR_OF_POOL_RUNS; i++) {
task_mem_pool_alloc_wait (&block, DEMOPOOL, 16); task_mem_pool_alloc_wait (&block, DEMOPOOL, 16);
task_mem_pool_free (&block); task_mem_pool_free (&block);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, PRINT_F (output_file, FORMAT,
"average alloc and dealloc memory pool block", "average alloc and dealloc memory pool block",
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, (2 * NR_OF_POOL_RUNS))); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, (2 * NR_OF_POOL_RUNS)));
} }
#endif /* MEMPOOL_BENCH */ #endif /* MEMPOOL_BENCH */

View file

@ -44,21 +44,21 @@
*/ */
void mutex_test (void) void mutex_test (void)
{ {
uint32_t et; /* elapsed time */ uint32_t et; /* elapsed time */
int i; int i;
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_MUTEX_RUNS; i++) { for (i = 0; i < NR_OF_MUTEX_RUNS; i++) {
task_mutex_lock_wait (DEMO_MUTEX); task_mutex_lock_wait (DEMO_MUTEX);
task_mutex_unlock (DEMO_MUTEX); task_mutex_unlock (DEMO_MUTEX);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "average lock and unlock mutex", 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 */ #endif /* MUTEX_BENCH */

View file

@ -44,19 +44,19 @@
*/ */
void call_test (void) void call_test (void)
{ {
uint32_t et; /* Elapsed Time */ uint32_t et; /* Elapsed Time */
int i; int i;
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_NOP_RUNS; i++) { for (i = 0; i < NR_OF_NOP_RUNS; i++) {
_task_nop(); _task_nop();
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "minimum VxMicro call time", 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 */ #endif /* MICROKERNEL_CALL_BENCH */

View file

@ -36,11 +36,11 @@
#ifdef FLOAT #ifdef FLOAT
#define PRINT_ALL_TO_N_HEADER_UNIT() \ #define PRINT_ALL_TO_N_HEADER_UNIT() \
PRINT_STRING ("| size(B) | time/packet (usec) | "\ PRINT_STRING ("| size(B) | time/packet (usec) | "\
" MB/sec |\n", output_file); " MB/sec |\n", output_file);
#define PRINT_ALL_TO_N() \ #define PRINT_ALL_TO_N() \
PRINT_F (output_file, \ PRINT_F (output_file, \
"|%5lu|%5lu|%10.3f|%10.3f|%10.3f|%10.3f|%10.3f|%10.3f|\n", \ "|%5lu|%5lu|%10.3f|%10.3f|%10.3f|%10.3f|%10.3f|%10.3f|\n", \
putsize, putsize, puttime[0] / 1000.0, puttime[1] / 1000.0, \ putsize, putsize, puttime[0] / 1000.0, puttime[1] / 1000.0, \
puttime[2] / 1000.0, \ puttime[2] / 1000.0, \
@ -49,12 +49,12 @@
(1000.0 * putsize) / puttime[2]) (1000.0 * putsize) / puttime[2])
#define PRINT_1_TO_N_HEADER() \ #define PRINT_1_TO_N_HEADER() \
PRINT_STRING ("| size(B) | time/packet (usec) | "\ PRINT_STRING ("| size(B) | time/packet (usec) | "\
" MB/sec |\n", output_file); \ " MB/sec |\n", output_file); \
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
#define PRINT_1_TO_N() \ #define PRINT_1_TO_N() \
PRINT_F (output_file, \ PRINT_F (output_file, \
"|%5lu|%5d|%10.3f|%10.3f|%10.3f|%10.3f|%10.3f|%10.3f|\n",\ "|%5lu|%5d|%10.3f|%10.3f|%10.3f|%10.3f|%10.3f|%10.3f|\n",\
putsize, \ putsize, \
getsize, \ getsize, \
@ -67,11 +67,11 @@
#else #else
#define PRINT_ALL_TO_N_HEADER_UNIT() \ #define PRINT_ALL_TO_N_HEADER_UNIT() \
PRINT_STRING ("| size(B) | time/packet (nsec) | "\ PRINT_STRING ("| size(B) | time/packet (nsec) | "\
" KB/sec |\n", output_file); " KB/sec |\n", output_file);
#define PRINT_ALL_TO_N() \ #define PRINT_ALL_TO_N() \
PRINT_F (output_file, \ PRINT_F (output_file, \
"|%5lu|%5lu|%10lu|%10lu|%10lu|%10lu|%10lu|%10lu|\n", \ "|%5lu|%5lu|%10lu|%10lu|%10lu|%10lu|%10lu|%10lu|\n", \
putsize, putsize, puttime[0], puttime[1], \ putsize, putsize, puttime[0], puttime[1], \
puttime[2], \ puttime[2], \
@ -80,12 +80,12 @@
(1000000 * putsize) / puttime[2]); (1000000 * putsize) / puttime[2]);
#define PRINT_1_TO_N_HEADER() \ #define PRINT_1_TO_N_HEADER() \
PRINT_STRING ("| size(B) | time/packet (nsec) | "\ PRINT_STRING ("| size(B) | time/packet (nsec) | "\
" KB/sec |\n", output_file); \ " KB/sec |\n", output_file); \
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
#define PRINT_1_TO_N() \ #define PRINT_1_TO_N() \
PRINT_F (output_file, \ PRINT_F (output_file, \
"|%5lu|%5d|%10lu|%10lu|%10lu|%10lu|%10lu|%10lu|\n", \ "|%5lu|%5d|%10lu|%10lu|%10lu|%10lu|%10lu|%10lu|\n", \
putsize, \ putsize, \
getsize, \ getsize, \
@ -117,42 +117,42 @@ int pipeput (kpipe_t pipe, K_PIPE_OPTION
*/ */
void pipe_test (void) void pipe_test (void)
{ {
uint32_t putsize; uint32_t putsize;
int getsize; int getsize;
uint32_t puttime[3]; uint32_t puttime[3];
int putcount; int putcount;
int pipe; int pipe;
kpriority_t TaskPrio; kpriority_t TaskPrio;
int prio; int prio;
GetInfo getinfo; GetInfo getinfo;
task_sem_reset (SEM0); task_sem_reset (SEM0);
task_sem_give (STARTRCV); 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 (dashline, output_file);
PRINT_STRING ("| " PRINT_STRING ("| "
"C H A N N E L M E A S U R E M E N T S" "C H A N N E L M E A S U R E M E N T S"
" |\n", output_file); " |\n", output_file);
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_STRING ("| Send data into a pipe towards a " PRINT_STRING ("| Send data into a pipe towards a "
"receiving high priority task and wait |\n", "receiving high priority task and wait |\n",
output_file); output_file);
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_STRING ("| " PRINT_STRING ("| "
"matching sizes (_ALL_N)" "matching sizes (_ALL_N)"
" |\n", output_file); " |\n", output_file);
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_ALL_TO_N_HEADER_UNIT (); PRINT_ALL_TO_N_HEADER_UNIT ();
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_STRING ("| put | get | no buf | small buf| big buf |" 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); PRINT_STRING (dashline, output_file);
for (putsize = 8; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) { for (putsize = 8; putsize <= MESSAGE_SIZE_PIPE; putsize <<= 1) {
for (pipe = 0; pipe < 3; pipe++) { for (pipe = 0; pipe < 3; pipe++) {
putcount = NR_OF_PIPE_RUNS; putcount = NR_OF_PIPE_RUNS;
pipeput (TestPipes[pipe], _ALL_N, putsize, putcount, pipeput (TestPipes[pipe], _ALL_N, putsize, putcount,
@ -162,10 +162,10 @@ void pipe_test (void)
} }
PRINT_ALL_TO_N (); PRINT_ALL_TO_N ();
} }
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
/* Test with two different sender priorities */ /* Test with two different sender priorities */
for (prio = 0; prio < 2; prio++) { for (prio = 0; prio < 2; prio++) {
/* non-buffered operation, non-matching (1_TO_N) */ /* non-buffered operation, non-matching (1_TO_N) */
if (prio == 0) { if (prio == 0) {
PRINT_STRING ("| " PRINT_STRING ("| "
@ -199,7 +199,7 @@ void pipe_test (void)
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
task_priority_set (task_id_get (), TaskPrio); task_priority_set (task_id_get (), TaskPrio);
} }
} }
/******************************************************************************* /*******************************************************************************
@ -212,22 +212,22 @@ void pipe_test (void)
*/ */
int pipeput ( int pipeput (
kpipe_t pipe, /* The pipe to be tested */ kpipe_t pipe, /* The pipe to be tested */
K_PIPE_OPTION option, /* _ALL_TO_N or _1_TO_N */ K_PIPE_OPTION option, /* _ALL_TO_N or _1_TO_N */
int size, /* data chunk size */ int size, /* data chunk size */
int count, /* number of data chunks */ int count, /* number of data chunks */
uint32_t *time /* total write time */ uint32_t *time /* total write time */
) )
{ {
int i; int i;
unsigned int t; unsigned int t;
int sizexferd_total = 0; int sizexferd_total = 0;
int size2xfer_total = size * count; int size2xfer_total = size * count;
/* first sync with the receiver */ /* first sync with the receiver */
task_sem_give (SEM0); task_sem_give (SEM0);
t = BENCH_START (); t = BENCH_START ();
for (i = 0; _1_TO_N == option || (i < count); i++) { for (i = 0; _1_TO_N == option || (i < count); i++) {
int sizexferd = 0; int sizexferd = 0;
int size2xfer = min(size, size2xfer_total - sizexferd_total); int size2xfer = min(size, size2xfer_total - sizexferd_total);
int ret; int ret;
@ -247,9 +247,9 @@ int pipeput (
return 1; return 1;
} }
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
if (bench_test_end () < 0) { if (bench_test_end () < 0) {
if (high_timer_overflow ()) { if (high_timer_overflow ()) {
PRINT_STRING ("| Timer overflow. Results are invalid ", PRINT_STRING ("| Timer overflow. Results are invalid ",
output_file); output_file);
@ -261,7 +261,7 @@ int pipeput (
PRINT_STRING (" |\n", PRINT_STRING (" |\n",
output_file); output_file);
} }
return 0; return 0;
} }
#endif /* PIPE_BENCH */ #endif /* PIPE_BENCH */

View file

@ -57,17 +57,17 @@ int pipeget (kpipe_t pipe, K_PIPE_OPTION option,
*/ */
void piperecvtask (void) void piperecvtask (void)
{ {
int getsize; int getsize;
unsigned int gettime; unsigned int gettime;
int getcount; int getcount;
int pipe; int pipe;
int prio; int prio;
GetInfo getinfo; GetInfo getinfo;
/* matching (ALL_N) */ /* matching (ALL_N) */
for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) { for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) {
for (pipe = 0; pipe < 3; pipe++) { for (pipe = 0; pipe < 3; pipe++) {
getcount = NR_OF_PIPE_RUNS; getcount = NR_OF_PIPE_RUNS;
pipeget (TestPipes[pipe], _ALL_N, getsize, pipeget (TestPipes[pipe], _ALL_N, getsize,
@ -79,7 +79,7 @@ void piperecvtask (void)
} }
} }
for (prio = 0; prio < 2; prio++) { for (prio = 0; prio < 2; prio++) {
/* non-matching (1_TO_N) */ /* non-matching (1_TO_N) */
for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) { for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) {
getcount = MESSAGE_SIZE_PIPE / getsize; getcount = MESSAGE_SIZE_PIPE / getsize;
@ -95,7 +95,7 @@ void piperecvtask (void)
} }
} }
} }
/******************************************************************************* /*******************************************************************************
@ -108,22 +108,22 @@ void piperecvtask (void)
*/ */
int pipeget ( int pipeget (
kpipe_t pipe, /* pipe to read data from */ kpipe_t pipe, /* pipe to read data from */
K_PIPE_OPTION option, /* _ALL_TO_N or _1_TO_N */ K_PIPE_OPTION option, /* _ALL_TO_N or _1_TO_N */
int size, /* data chunk size */ int size, /* data chunk size */
int count, /* number of data chunks */ int count, /* number of data chunks */
unsigned int* time /* total write time */ unsigned int* time /* total write time */
) )
{ {
int i; int i;
unsigned int t; unsigned int t;
int sizexferd_total = 0; int sizexferd_total = 0;
int size2xfer_total = size * count; int size2xfer_total = size * count;
/* sync with the sender */ /* sync with the sender */
task_sem_take_wait (SEM0); task_sem_take_wait (SEM0);
t = BENCH_START (); t = BENCH_START ();
for (i = 0; _1_TO_N == option || (i < count); i++) { for (i = 0; _1_TO_N == option || (i < count); i++) {
int sizexferd = 0; int sizexferd = 0;
int size2xfer = min(size, size2xfer_total - sizexferd_total); int size2xfer = min(size, size2xfer_total - sizexferd_total);
int ret; int ret;
@ -144,9 +144,9 @@ int pipeget (
return 1; return 1;
} }
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
if (bench_test_end () < 0) { if (bench_test_end () < 0) {
if (high_timer_overflow ()) { if (high_timer_overflow ()) {
PRINT_STRING ("| Timer overflow. Results are invalid ", PRINT_STRING ("| Timer overflow. Results are invalid ",
output_file); output_file);
@ -158,7 +158,7 @@ int pipeget (
PRINT_STRING (" |\n", PRINT_STRING (" |\n",
output_file); output_file);
} }
return 0; return 0;
} }
#endif /* PIPE_BENCH */ #endif /* PIPE_BENCH */

View file

@ -42,8 +42,8 @@
#include "receiver.h" #include "receiver.h"
char data_recv[OCTET_TO_SIZEOFUNIT (MESSAGE_SIZE)] = { char data_recv[OCTET_TO_SIZEOFUNIT (MESSAGE_SIZE)] = {
0 0
}; };
void dequtask (void); void dequtask (void);
void waittask (void); void waittask (void);
@ -60,22 +60,22 @@ void piperecvtask (void);
*/ */
void recvtask (void) void recvtask (void)
{ {
/* order must be compatible with master.c ! */ /* order must be compatible with master.c ! */
#ifdef FIFO_BENCH #ifdef FIFO_BENCH
task_sem_take_wait (STARTRCV); task_sem_take_wait (STARTRCV);
dequtask (); dequtask ();
#endif #endif
#ifdef SEMA_BENCH #ifdef SEMA_BENCH
task_sem_take_wait (STARTRCV); task_sem_take_wait (STARTRCV);
waittask (); waittask ();
#endif #endif
#ifdef MAILBOX_BENCH #ifdef MAILBOX_BENCH
task_sem_take_wait (STARTRCV); task_sem_take_wait (STARTRCV);
mailrecvtask (); mailrecvtask ();
#endif #endif
#ifdef PIPE_BENCH #ifdef PIPE_BENCH
task_sem_take_wait (STARTRCV); task_sem_take_wait (STARTRCV);
piperecvtask (); piperecvtask ();
#endif #endif
} }

View file

@ -39,10 +39,10 @@
/* type defines. */ /* type defines. */
typedef struct { typedef struct {
int count; int count;
unsigned int time; unsigned int time;
int size; int size;
} GetInfo; } GetInfo;
/* global data */ /* global data */
extern char data_recv[OCTET_TO_SIZEOFUNIT (MESSAGE_SIZE)]; extern char data_recv[OCTET_TO_SIZEOFUNIT (MESSAGE_SIZE)];

View file

@ -45,104 +45,104 @@
*/ */
void sema_test (void) void sema_test (void)
{ {
uint32_t et; /* elapsed Time */ uint32_t et; /* elapsed Time */
int i; int i;
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) { for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give (SEM0); task_sem_give (SEM0);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "signal semaphore", 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_reset (SEM1);
task_sem_give (STARTRCV); task_sem_give (STARTRCV);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) { for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give (SEM1); task_sem_give (SEM1);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "signal to waiting high pri task", 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) { for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give (SEM1); task_sem_give (SEM1);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, PRINT_F (output_file, FORMAT,
"signal to waiting high pri task, with timeout", "signal to waiting high pri task, 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) { for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give (SEM2); task_sem_give (SEM2);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "signal to waitm (2)", 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) { for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give (SEM2); task_sem_give (SEM2);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "signal to waitm (2), with timeout", 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) { for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give (SEM3); task_sem_give (SEM3);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "signal to waitm (3)", 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) { for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give (SEM3); task_sem_give (SEM3);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "signal to waitm (3), with timeout", 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) { for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give (SEM4); task_sem_give (SEM4);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "signal to waitm (4)", 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 (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) { for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
task_sem_give (SEM4); task_sem_give (SEM4);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
check_result (); check_result ();
PRINT_F (output_file, FORMAT, "signal to waitm (4), with timeout", 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 */ #endif /* SEMA_BENCH */

View file

@ -47,38 +47,38 @@
*/ */
void waittask (void) void waittask (void)
{ {
int i; int i;
ksem_t slist[5]; ksem_t slist[5];
slist[0] = SEM1; slist[0] = SEM1;
slist[1] = SEM2; slist[1] = SEM2;
slist[2] = ENDLIST; slist[2] = ENDLIST;
slist[3] = ENDLIST; slist[3] = ENDLIST;
slist[4] = ENDLIST; slist[4] = ENDLIST;
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_take_wait (SEM1); task_sem_take_wait (SEM1);
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_take_wait_timeout (SEM1, SEMA_WAIT_TIME); task_sem_take_wait_timeout (SEM1, SEMA_WAIT_TIME);
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait (slist); task_sem_group_take_wait (slist);
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait_timeout (slist, SEMA_WAIT_TIME); task_sem_group_take_wait_timeout (slist, SEMA_WAIT_TIME);
slist[2] = SEM3; slist[2] = SEM3;
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait (slist); task_sem_group_take_wait (slist);
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait_timeout (slist, SEMA_WAIT_TIME); task_sem_group_take_wait_timeout (slist, SEMA_WAIT_TIME);
slist[3] = SEM4; slist[3] = SEM4;
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait (slist); task_sem_group_take_wait (slist);
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++)
task_sem_group_take_wait_timeout (slist, SEMA_WAIT_TIME); task_sem_group_take_wait_timeout (slist, SEMA_WAIT_TIME);
} }
#endif /* SEMA_BENCH */ #endif /* SEMA_BENCH */

View file

@ -56,68 +56,68 @@ extern uint64_t __main_tsc; /* timestamp when main() begins executing */
extern uint64_t __idle_tsc; /* timestamp when CPU went idle */ extern uint64_t __idle_tsc; /* timestamp when CPU went idle */
void bootTimeTask (void) void bootTimeTask (void)
{ {
uint64_t task_tsc; /* timestamp at beginning of first task */ uint64_t task_tsc; /* timestamp at beginning of first task */
uint64_t _start_us; /* being of __start timestamp in us */ uint64_t _start_us; /* being of __start timestamp in us */
uint64_t main_us; /* begin of main timestamp in us */ uint64_t main_us; /* begin of main timestamp in us */
uint64_t task_us; /* begin of task timestamp in us */ uint64_t task_us; /* begin of task timestamp in us */
uint64_t s_main_tsc; /* __start->main timestamp */ uint64_t s_main_tsc; /* __start->main timestamp */
uint64_t s_task_tsc; /*__start->task timestamp */ uint64_t s_task_tsc; /*__start->task timestamp */
#ifndef CONFIG_NANOKERNEL #ifndef CONFIG_NANOKERNEL
uint64_t idle_us; /* begin of idle timestamp in us */ uint64_t idle_us; /* begin of idle timestamp in us */
uint64_t s_idle_tsc; /*__start->idle timestamp */ uint64_t s_idle_tsc; /*__start->idle timestamp */
#endif /* ! CONFIG_NANOKERNEL */ #endif /* ! CONFIG_NANOKERNEL */
task_tsc = _NanoTscRead(); task_tsc = _NanoTscRead();
#ifndef CONFIG_NANOKERNEL #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); task_sleep(1);
#endif /* ! CONFIG_NANOKERNEL */ #endif /* ! CONFIG_NANOKERNEL */
_start_us = __start_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ; _start_us = __start_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ;
s_main_tsc = __main_tsc-__start_tsc; s_main_tsc = __main_tsc-__start_tsc;
main_us = s_main_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ; main_us = s_main_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ;
s_task_tsc = task_tsc-__start_tsc; s_task_tsc = task_tsc-__start_tsc;
task_us = s_task_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ; task_us = s_task_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ;
#ifndef CONFIG_NANOKERNEL #ifndef CONFIG_NANOKERNEL
s_idle_tsc = __idle_tsc-__start_tsc; s_idle_tsc = __idle_tsc-__start_tsc;
idle_us = s_idle_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ; idle_us = s_idle_tsc / CONFIG_CPU_CLOCK_FREQ_MHZ;
#endif #endif
/* Indicate start for sanity test suite */ /* Indicate start for sanity test suite */
TC_START ("Boot Time Measurement"); TC_START ("Boot Time Measurement");
/* Only print lower 32bit of time result */ /* Only print lower 32bit of time result */
#ifdef CONFIG_NANOKERNEL #ifdef CONFIG_NANOKERNEL
TC_PRINT("NanoKernel Boot Result: Clock Frequency: %d MHz\n", TC_PRINT("NanoKernel Boot Result: Clock Frequency: %d MHz\n",
CONFIG_CPU_CLOCK_FREQ_MHZ); CONFIG_CPU_CLOCK_FREQ_MHZ);
#else /* CONFIG_MICROKERNEL */ #else /* CONFIG_MICROKERNEL */
TC_PRINT("MicroKernel Boot Result: Clock Frequency: %d MHz\n", TC_PRINT("MicroKernel Boot Result: Clock Frequency: %d MHz\n",
CONFIG_CPU_CLOCK_FREQ_MHZ); CONFIG_CPU_CLOCK_FREQ_MHZ);
#endif #endif
TC_PRINT("__start : %d cycles, %d us\n", TC_PRINT("__start : %d cycles, %d us\n",
(uint32_t)(__start_tsc & 0xFFFFFFFFULL), (uint32_t)(__start_tsc & 0xFFFFFFFFULL),
(uint32_t) (_start_us & 0xFFFFFFFFULL)); (uint32_t) (_start_us & 0xFFFFFFFFULL));
TC_PRINT("_start->main(): %d cycles, %d us\n", TC_PRINT("_start->main(): %d cycles, %d us\n",
(uint32_t)(s_main_tsc & 0xFFFFFFFFULL), (uint32_t)(s_main_tsc & 0xFFFFFFFFULL),
(uint32_t) (main_us & 0xFFFFFFFFULL)); (uint32_t) (main_us & 0xFFFFFFFFULL));
TC_PRINT("_start->task : %d cycles, %d us\n", TC_PRINT("_start->task : %d cycles, %d us\n",
(uint32_t)(s_task_tsc & 0xFFFFFFFFULL), (uint32_t)(s_task_tsc & 0xFFFFFFFFULL),
(uint32_t) (task_us & 0xFFFFFFFFULL)); (uint32_t) (task_us & 0xFFFFFFFFULL));
#ifndef CONFIG_NANOKERNEL /* CONFIG_MICROKERNEL */ #ifndef CONFIG_NANOKERNEL /* CONFIG_MICROKERNEL */
TC_PRINT("_start->idle : %d cycles, %d us\n", TC_PRINT("_start->idle : %d cycles, %d us\n",
(uint32_t)(s_idle_tsc & 0xFFFFFFFFULL), (uint32_t)(s_idle_tsc & 0xFFFFFFFFULL),
(uint32_t) (idle_us & 0xFFFFFFFFULL)); (uint32_t) (idle_us & 0xFFFFFFFFULL));
#endif #endif
TC_PRINT("Boot Time Measurement finished\n"); TC_PRINT("Boot Time Measurement finished\n");
// for sanity regression test utility. // for sanity regression test utility.
TC_END_RESULT(TC_PASS); TC_END_RESULT(TC_PASS);
TC_END_REPORT(TC_PASS); TC_END_REPORT(TC_PASS);
} }
#ifdef CONFIG_NANOKERNEL #ifdef CONFIG_NANOKERNEL
@ -131,13 +131,13 @@ char fiberStack[512];
*/ */
void main (void) void main (void)
{ {
/* record timestamp for nanokernel's main() function */ /* record timestamp for nanokernel's main() function */
__main_tsc = _NanoTscRead(); __main_tsc = _NanoTscRead();
/* create bootTime fibers */ /* create bootTime fibers */
task_fiber_start (fiberStack, 512, 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 */ #endif /* CONFIG_NANOKERNEL */

View file

@ -85,64 +85,64 @@ NANO_CPU_INT_REGISTER (isrDummyIntStub, TEST_SOFT_INT, 0);
/* pointer array ensures specified functions are linked into the image */ /* pointer array ensures specified functions are linked into the image */
static pfunc func_array[] = { static pfunc func_array[] = {
/* event functions */ /* event functions */
(pfunc)task_event_send, (pfunc)task_event_send,
(pfunc)_task_event_recv, (pfunc)_task_event_recv,
/* mutex functions */ /* mutex functions */
(pfunc)_task_mutex_lock, (pfunc)_task_mutex_lock,
(pfunc)_task_mutex_unlock, (pfunc)_task_mutex_unlock,
/* FIFO functions */ /* FIFO functions */
(pfunc)_task_fifo_put, (pfunc)_task_fifo_put,
(pfunc)_task_fifo_get, (pfunc)_task_fifo_get,
(pfunc)_task_fifo_ioctl, (pfunc)_task_fifo_ioctl,
/* memory map functions */ /* memory map functions */
(pfunc)task_mem_map_used_get, (pfunc)task_mem_map_used_get,
(pfunc)_task_mem_map_alloc, (pfunc)_task_mem_map_alloc,
(pfunc)_task_mem_map_free, (pfunc)_task_mem_map_free,
#ifdef TEST_max #ifdef TEST_max
/* task device interrupt functions */ /* task device interrupt functions */
(pfunc)task_irq_alloc, (pfunc)task_irq_alloc,
(pfunc)_task_irq_test, (pfunc)_task_irq_test,
(pfunc)task_irq_ack, (pfunc)task_irq_ack,
(pfunc)task_irq_free, (pfunc)task_irq_free,
/* semaphore functions */ /* semaphore functions */
(pfunc)isr_sem_give, (pfunc)isr_sem_give,
(pfunc)task_sem_give, (pfunc)task_sem_give,
(pfunc)task_sem_group_give, (pfunc)task_sem_group_give,
(pfunc)task_sem_count_get, (pfunc)task_sem_count_get,
(pfunc)task_sem_reset, (pfunc)task_sem_reset,
(pfunc)task_sem_group_reset, (pfunc)task_sem_group_reset,
(pfunc)_task_sem_take, (pfunc)_task_sem_take,
(pfunc)_task_sem_group_take, (pfunc)_task_sem_group_take,
/* pipe functions */ /* pipe functions */
(pfunc)task_pipe_put, (pfunc)task_pipe_put,
(pfunc)task_pipe_put_wait, (pfunc)task_pipe_put_wait,
(pfunc)task_pipe_put_wait_timeout, (pfunc)task_pipe_put_wait_timeout,
(pfunc)task_pipe_get, (pfunc)task_pipe_get,
(pfunc)task_pipe_get_wait, (pfunc)task_pipe_get_wait,
(pfunc)task_pipe_get_wait_timeout, (pfunc)task_pipe_get_wait_timeout,
(pfunc)_task_pipe_put_async, (pfunc)_task_pipe_put_async,
(pfunc)_task_pipe_put, (pfunc)_task_pipe_put,
(pfunc)_task_pipe_get, (pfunc)_task_pipe_get,
/* mailbox functions */ /* mailbox functions */
(pfunc)_task_mbox_put, (pfunc)_task_mbox_put,
(pfunc)_task_mbox_get, (pfunc)_task_mbox_get,
(pfunc)_task_mbox_put_async, (pfunc)_task_mbox_put_async,
(pfunc)_task_mbox_data_get, (pfunc)_task_mbox_data_get,
(pfunc)_task_mbox_data_get_async_block, (pfunc)_task_mbox_data_get_async_block,
/* memory pool functions */ /* memory pool functions */
(pfunc)_task_mem_pool_alloc, (pfunc)_task_mem_pool_alloc,
(pfunc)task_mem_pool_free, (pfunc)task_mem_pool_free,
(pfunc)task_mem_pool_defragment, (pfunc)task_mem_pool_defragment,
/* task functions */ /* task functions */
(pfunc)_task_ioctl, (pfunc)_task_ioctl,
(pfunc)_task_group_ioctl, (pfunc)_task_group_ioctl,
(pfunc)task_abort_handler_set, (pfunc)task_abort_handler_set,
(pfunc)task_entry_set, (pfunc)task_entry_set,
(pfunc)task_priority_set, (pfunc)task_priority_set,
(pfunc)task_sleep, (pfunc)task_sleep,
(pfunc)task_yield, (pfunc)task_yield,
#endif /* TEST_max */ #endif /* TEST_max */
}; };
/******************************************************************************* /*******************************************************************************
* *
@ -152,9 +152,9 @@ static pfunc func_array[] = {
*/ */
void dummyIsr (void *unused) void dummyIsr (void *unused)
{ {
ARG_UNUSED (unused); ARG_UNUSED (unused);
} }
#ifdef TEST_reg #ifdef TEST_reg
/******************************************************************************* /*******************************************************************************
@ -169,13 +169,13 @@ void dummyIsr (void *unused)
*/ */
static void isrDummyIntStub (void *unused) static void isrDummyIntStub (void *unused)
{ {
ARG_UNUSED (unused); ARG_UNUSED (unused);
isr_dummy(); isr_dummy();
CODE_UNREACHABLE; CODE_UNREACHABLE;
} }
#endif /* TEST_reg */ #endif /* TEST_reg */
/******************************************************************************* /*******************************************************************************
@ -191,23 +191,23 @@ static void isrDummyIntStub (void *unused)
*/ */
void fgTaskEntry (void) void fgTaskEntry (void)
{ {
#ifdef TEST_max #ifdef TEST_max
/* dynamically link in dummy ISR */ /* dynamically link in dummy ISR */
irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr, irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr,
(void *) 0, isrDummyHandlerStub); (void *) 0, isrDummyHandlerStub);
#endif /* TEST_max */ #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 #ifdef TEST_max
printf ((char *)MESSAGE, func_array); printf ((char *)MESSAGE, func_array);
#else #else
printk ((char *)MESSAGE, func_array); printk ((char *)MESSAGE, func_array);
#endif /* TEST_max */ #endif /* TEST_max */
while (1) { while (1) {
i++; i++;
} }
} }
#endif /* TEST_min */ #endif /* TEST_min */

View file

@ -54,25 +54,25 @@ int errorCount = 0; /* track number of errors */
*/ */
void nanoTest (void) void nanoTest (void)
{ {
PRINT_NANO_BANNER (); PRINT_NANO_BANNER ();
PRINT_TIME_BANNER(); PRINT_TIME_BANNER();
nanoIntLatency (); nanoIntLatency ();
printDashLine (); printDashLine ();
nanoIntToFiber (); nanoIntToFiber ();
printDashLine (); printDashLine ();
nanoIntToFiberSem (); nanoIntToFiberSem ();
printDashLine (); printDashLine ();
nanoCtxSwitch (); nanoCtxSwitch ();
printDashLine (); printDashLine ();
nanoIntLockUnlock (); nanoIntLockUnlock ();
printDashLine (); printDashLine ();
} }
#ifdef CONFIG_NANOKERNEL #ifdef CONFIG_NANOKERNEL
/******************************************************************************* /*******************************************************************************
@ -85,14 +85,14 @@ void nanoTest (void)
*/ */
void main (void) void main (void)
{ {
bench_test_init (); bench_test_init ();
nanoTest (); nanoTest ();
PRINT_END_BANNER (); PRINT_END_BANNER ();
TC_END_REPORT (errorCount); TC_END_REPORT (errorCount);
} }
#else #else
@ -112,25 +112,25 @@ void microTaskSwitchYield (void);
*/ */
void microTest (void) void microTest (void)
{ {
PRINT_MICRO_BANNER (); PRINT_MICRO_BANNER ();
PRINT_TIME_BANNER(); PRINT_TIME_BANNER();
microIntToTask (); microIntToTask ();
printDashLine (); printDashLine ();
microIntToTaskEvt (); microIntToTaskEvt ();
printDashLine (); printDashLine ();
microSemaLockUnlock (); microSemaLockUnlock ();
printDashLine (); printDashLine ();
microMutexLockUnlock (); microMutexLockUnlock ();
printDashLine (); printDashLine ();
microTaskSwitchYield (); microTaskSwitchYield ();
printDashLine (); printDashLine ();
} }
/******************************************************************************* /*******************************************************************************
* *
@ -142,13 +142,13 @@ void microTest (void)
*/ */
void microMain (void) void microMain (void)
{ {
bench_test_init (); bench_test_init ();
nanoTest (); nanoTest ();
microTest (); microTest ();
PRINT_END_BANNER (); PRINT_END_BANNER ();
TC_END_REPORT (errorCount); TC_END_REPORT (errorCount);
} }
#endif /* CONFIG_NANOKERNEL */ #endif /* CONFIG_NANOKERNEL */

View file

@ -58,12 +58,12 @@ static uint32_t timestamp;
*/ */
static void latencyTestIsr (void *unused) static void latencyTestIsr (void *unused)
{ {
ARG_UNUSED (unused); ARG_UNUSED (unused);
flagVar = 1; flagVar = 1;
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -78,16 +78,16 @@ static void latencyTestIsr (void *unused)
*/ */
static void makeInt (void) static void makeInt (void)
{ {
initSwInterrupt (latencyTestIsr); initSwInterrupt (latencyTestIsr);
flagVar = 0; flagVar = 0;
raiseIntFunc (); raiseIntFunc ();
if (flagVar != 1) { if (flagVar != 1) {
PRINT_FORMAT (" Flag variable has not changed. FAILED\n"); PRINT_FORMAT (" Flag variable has not changed. FAILED\n");
} }
else else
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -99,16 +99,16 @@ static void makeInt (void)
*/ */
int microIntToTask (void) int microIntToTask (void)
{ {
PRINT_FORMAT (" 1- Measure time to switch from ISR to back to" PRINT_FORMAT (" 1- Measure time to switch from ISR to back to"
" interrupted task"); " interrupted task");
TICK_SYNCH (); TICK_SYNCH ();
makeInt (); makeInt ();
if (flagVar == 1) { if (flagVar == 1) {
PRINT_FORMAT (" switching time is %lu tcs = %lu nsec", 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; return 0;
} }
#endif /* MICROKERNEL */ #endif /* MICROKERNEL */

View file

@ -60,12 +60,12 @@ static uint32_t timestamp = 0;
*/ */
static void latencyTestIsr (void *unused) static void latencyTestIsr (void *unused)
{ {
ARG_UNUSED (unused); ARG_UNUSED (unused);
isr_event_send (EVENT0); isr_event_send (EVENT0);
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -81,12 +81,12 @@ static void latencyTestIsr (void *unused)
*/ */
void microInt (void) void microInt (void)
{ {
task_sem_take_wait (INTSEMA); task_sem_take_wait (INTSEMA);
setSwInterrupt (latencyTestIsr); setSwInterrupt (latencyTestIsr);
raiseIntFunc (); raiseIntFunc ();
task_suspend (task_id_get ()); task_suspend (task_id_get ());
} }
/******************************************************************************* /*******************************************************************************
* *
@ -98,16 +98,16 @@ void microInt (void)
*/ */
int microIntToTaskEvt (void) int microIntToTaskEvt (void)
{ {
PRINT_FORMAT (" 2- Measure time from ISR to executing a different task" PRINT_FORMAT (" 2- Measure time from ISR to executing a different task"
" (rescheduled)"); " (rescheduled)");
TICK_SYNCH (); TICK_SYNCH ();
task_sem_give (INTSEMA); task_sem_give (INTSEMA);
task_event_recv_wait (EVENT0); task_event_recv_wait (EVENT0);
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
PRINT_FORMAT (" switch time is %lu tcs = %lu nsec", 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; return 0;
} }
#endif /* CONFIG_MICROKERNEL */ #endif /* CONFIG_MICROKERNEL */

View file

@ -66,44 +66,44 @@ static uint32_t timestamp;
*/ */
int microSemaLockUnlock (void) int microSemaLockUnlock (void)
{ {
int i; int i;
PRINT_FORMAT (" 3- Measure average time to signal a sema then test" PRINT_FORMAT (" 3- Measure average time to signal a sema then test"
" that sema"); " that sema");
bench_test_start (); bench_test_start ();
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = SEMASTART; i <= SEMAEND; i++) { for (i = SEMASTART; i <= SEMAEND; i++) {
task_sem_give (i); task_sem_give (i);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
if (bench_test_end () == 0) { if (bench_test_end () == 0) {
PRINT_FORMAT (" Average semaphore signal time %lu tcs = %lu nsec", PRINT_FORMAT (" Average semaphore signal time %lu tcs = %lu nsec",
timestamp / N_TEST_SEMA, timestamp / N_TEST_SEMA,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA));
} }
else { else {
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
bench_test_start (); bench_test_start ();
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = SEMASTART; i <= SEMAEND; i++) { for (i = SEMASTART; i <= SEMAEND; i++) {
task_sem_take_wait (i); task_sem_take_wait (i);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
if (bench_test_end () == 0) { if (bench_test_end () == 0) {
PRINT_FORMAT (" Average semaphore test time %lu tcs = %lu nsec", PRINT_FORMAT (" Average semaphore test time %lu tcs = %lu nsec",
timestamp / N_TEST_SEMA, timestamp / N_TEST_SEMA,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA));
} }
else { else {
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
return 0; return 0;
} }
/******************************************************************************* /*******************************************************************************
* *
@ -118,28 +118,28 @@ int microSemaLockUnlock (void)
*/ */
int microMutexLockUnlock (void) int microMutexLockUnlock (void)
{ {
int i; int i;
PRINT_FORMAT (" 4- Measure average time to lock a mutex then" PRINT_FORMAT (" 4- Measure average time to lock a mutex then"
" unlock that mutex"); " unlock that mutex");
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = 0; i < N_TEST_MUTEX; i++) { 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); timestamp = TIME_STAMP_DELTA_GET (timestamp);
PRINT_FORMAT (" Average time to lock the mutex %lu tcs = %lu nsec", PRINT_FORMAT (" Average time to lock the mutex %lu tcs = %lu nsec",
timestamp / N_TEST_MUTEX, timestamp / N_TEST_MUTEX,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_MUTEX)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_MUTEX));
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = 0; i <= N_TEST_MUTEX; i++) { for (i = 0; i <= N_TEST_MUTEX; i++) {
task_mutex_unlock (TEST_MUTEX); task_mutex_unlock (TEST_MUTEX);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
PRINT_FORMAT (" Average time to unlock the mutex %lu tcs = %lu nsec", PRINT_FORMAT (" Average time to unlock the mutex %lu tcs = %lu nsec",
timestamp / N_TEST_MUTEX, timestamp / N_TEST_MUTEX,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_MUTEX)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_MUTEX));
return 0; return 0;
} }
#endif /* CONFIG_MICROKERNEL */ #endif /* CONFIG_MICROKERNEL */

View file

@ -62,12 +62,12 @@ static uint32_t helper_task_iterations = 0;
*/ */
void yieldingTask (void) void yieldingTask (void)
{ {
while (helper_task_iterations < NB_OF_YIELD) { while (helper_task_iterations < NB_OF_YIELD) {
task_yield (); task_yield ();
helper_task_iterations++; helper_task_iterations++;
} }
} }
/******************************************************************************* /*******************************************************************************
* *
@ -79,30 +79,30 @@ void yieldingTask (void)
*/ */
void microTaskSwitchYield (void) void microTaskSwitchYield (void)
{ {
uint32_t iterations = 0; uint32_t iterations = 0;
int32_t delta; int32_t delta;
uint32_t timestamp; uint32_t timestamp;
PRINT_FORMAT (" 5- Measure average context switch time between tasks using" PRINT_FORMAT (" 5- Measure average context switch time between tasks using"
" (task_yield)"); " (task_yield)");
bench_test_start (); 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); task_start (YIELDTASK);
/* get initial timestamp */ /* get initial timestamp */
timestamp = TIME_STAMP_DELTA_GET (0); 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) { while (iterations < NB_OF_YIELD && helper_task_iterations < NB_OF_YIELD) {
task_yield (); task_yield ();
iterations++; 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); timestamp = TIME_STAMP_DELTA_GET (timestamp);
/* Ensure both helper and this routine were context switching back & forth. /* Ensure both helper and this routine were context switching back & forth.
* For execution to reach the line below, either this routine or helper * For execution to reach the line below, either this routine or helper
@ -110,12 +110,12 @@ void microTaskSwitchYield (void)
* iteration away from reaching NB_OF_YIELD if execute was switching back * iteration away from reaching NB_OF_YIELD if execute was switching back
* and forth. * and forth.
*/ */
delta = iterations - helper_task_iterations; delta = iterations - helper_task_iterations;
if (bench_test_end () < 0) { if (bench_test_end () < 0) {
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
else if (abs (delta) > 1) { else if (abs (delta) > 1) {
/* expecting even alternating context switch, seems one routine /* expecting even alternating context switch, seems one routine
* called yield without the other having chance to execute * called yield without the other having chance to execute
*/ */
@ -123,7 +123,7 @@ void microTaskSwitchYield (void)
PRINT_FORMAT (" Error, iteration:%lu, helper iteration:%lu", PRINT_FORMAT (" Error, iteration:%lu, helper iteration:%lu",
iterations, helper_task_iterations); iterations, helper_task_iterations);
} }
else { else {
/* task_yield is called (iterations + helper_task_iterations) /* task_yield is called (iterations + helper_task_iterations)
* times in total. * times in total.
*/ */
@ -133,6 +133,6 @@ void microTaskSwitchYield (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp,
(iterations + helper_task_iterations))); (iterations + helper_task_iterations)));
} }
} }
#endif #endif

View file

@ -77,16 +77,16 @@ static volatile int ctxSwitchBalancer = 0;
*/ */
static void fiberOne (void) static void fiberOne (void)
{ {
nano_fiber_sem_take_wait (&syncSema); nano_fiber_sem_take_wait (&syncSema);
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
while (ctxSwitchCounter < NCTXSWITCH) { while (ctxSwitchCounter < NCTXSWITCH) {
fiber_yield (); fiber_yield ();
ctxSwitchCounter++; ctxSwitchCounter++;
ctxSwitchBalancer--; ctxSwitchBalancer--;
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -101,14 +101,14 @@ static void fiberOne (void)
*/ */
static void fiberTwo (void) static void fiberTwo (void)
{ {
nano_fiber_sem_give (&syncSema); nano_fiber_sem_give (&syncSema);
while (ctxSwitchCounter < NCTXSWITCH) { while (ctxSwitchCounter < NCTXSWITCH) {
fiber_yield (); fiber_yield ();
ctxSwitchCounter++; ctxSwitchCounter++;
ctxSwitchBalancer++; ctxSwitchBalancer++;
} }
} }
/******************************************************************************* /*******************************************************************************
* *
@ -120,27 +120,27 @@ static void fiberTwo (void)
*/ */
int nanoCtxSwitch (void) int nanoCtxSwitch (void)
{ {
PRINT_FORMAT (" 4- Measure average context switch time between fibers"); PRINT_FORMAT (" 4- Measure average context switch time between fibers");
nano_sem_init (&syncSema); nano_sem_init (&syncSema);
ctxSwitchCounter = 0; ctxSwitchCounter = 0;
ctxSwitchBalancer = 0; ctxSwitchBalancer = 0;
bench_test_start (); bench_test_start ();
task_fiber_start (&fiberOneStack[0], STACKSIZE, 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, 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) { 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) { else if (bench_test_end () != 0) {
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
else else
PRINT_FORMAT (" Average context switch time is %lu tcs = %lu nsec", PRINT_FORMAT (" Average context switch time is %lu tcs = %lu nsec",
timestamp / ctxSwitchCounter, timestamp / ctxSwitchCounter,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, ctxSwitchCounter)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, ctxSwitchCounter));
return 0; return 0;
} }

View file

@ -60,11 +60,11 @@ static uint32_t timestamp;
*/ */
static void latencyTestIsr (void *unused) static void latencyTestIsr (void *unused)
{ {
ARG_UNUSED (unused); ARG_UNUSED (unused);
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -79,11 +79,11 @@ static void latencyTestIsr (void *unused)
*/ */
static void fiberInt (void) static void fiberInt (void)
{ {
initSwInterrupt (latencyTestIsr); initSwInterrupt (latencyTestIsr);
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
raiseIntFunc (); raiseIntFunc ();
} }
/******************************************************************************* /*******************************************************************************
* *
@ -95,12 +95,12 @@ static void fiberInt (void)
*/ */
int nanoIntLatency (void) int nanoIntLatency (void)
{ {
PRINT_FORMAT (" 1- Measure time to switch from fiber to ISR execution"); PRINT_FORMAT (" 1- Measure time to switch from fiber to ISR execution");
TICK_SYNCH (); TICK_SYNCH ();
task_fiber_start (&fiberStack[0], STACKSIZE, 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", 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; return 0;
} }

View file

@ -59,48 +59,48 @@ static uint32_t timestamp = 0;
*/ */
int nanoIntLockUnlock (void) int nanoIntLockUnlock (void)
{ {
int i; int i;
unsigned int mask; unsigned int mask;
PRINT_FORMAT (" 5- Measure average time to lock then unlock interrupts"); 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" PRINT_FORMAT (" 5.1- When each lock and unlock is executed as a function"
" call"); " call");
bench_test_start (); bench_test_start ();
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = 0; i < NTESTS; i++) { for (i = 0; i < NTESTS; i++) {
mask = irq_lock (); mask = irq_lock ();
irq_unlock (mask); irq_unlock (mask);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
if (bench_test_end () == 0) { if (bench_test_end () == 0) {
PRINT_FORMAT (" Average time for lock then unlock " PRINT_FORMAT (" Average time for lock then unlock "
"is %lu tcs = %lu nsec", "is %lu tcs = %lu nsec",
timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS)); timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS));
} }
else { else {
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
PRINT_FORMAT (" "); PRINT_FORMAT (" ");
PRINT_FORMAT (" 5.2- When each lock and unlock is executed as inline" PRINT_FORMAT (" 5.2- When each lock and unlock is executed as inline"
" function call"); " function call");
bench_test_start (); bench_test_start ();
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = 0; i < NTESTS; i++) { for (i = 0; i < NTESTS; i++) {
mask = irq_lock_inline (); mask = irq_lock_inline ();
irq_unlock_inline (mask); irq_unlock_inline (mask);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
if (bench_test_end () == 0) { if (bench_test_end () == 0) {
PRINT_FORMAT (" Average time for lock then unlock " PRINT_FORMAT (" Average time for lock then unlock "
"is %lu tcs = %lu nsec", "is %lu tcs = %lu nsec",
timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS)); timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS));
} }
else { else {
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
return 0; return 0;
} }

View file

@ -62,12 +62,12 @@ static uint32_t timestamp;
*/ */
static void latencyTestIsr (void *unused) static void latencyTestIsr (void *unused)
{ {
ARG_UNUSED (unused); ARG_UNUSED (unused);
flagVar = 1; flagVar = 1;
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -82,16 +82,16 @@ static void latencyTestIsr (void *unused)
*/ */
static void fiberInt (void) static void fiberInt (void)
{ {
setSwInterrupt (latencyTestIsr); setSwInterrupt (latencyTestIsr);
flagVar = 0; flagVar = 0;
raiseIntFunc (); raiseIntFunc ();
if (flagVar != 1) { if (flagVar != 1) {
PRINT_FORMAT (" Flag variable has not changed. FAILED"); PRINT_FORMAT (" Flag variable has not changed. FAILED");
} }
else else
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -103,15 +103,15 @@ static void fiberInt (void)
*/ */
int nanoIntToFiber (void) int nanoIntToFiber (void)
{ {
PRINT_FORMAT (" 2- Measure time to switch from ISR back to interrupted" PRINT_FORMAT (" 2- Measure time to switch from ISR back to interrupted"
" fiber"); " fiber");
TICK_SYNCH (); TICK_SYNCH ();
task_fiber_start (&fiberStack[0], STACKSIZE, 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) { if (flagVar == 1) {
PRINT_FORMAT (" switching time is %lu tcs = %lu nsec", 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; return 0;
} }

View file

@ -73,12 +73,12 @@ static uint32_t timestamp = 0;
*/ */
static void latencyTestIsr (void *unused) static void latencyTestIsr (void *unused)
{ {
ARG_UNUSED (unused); ARG_UNUSED (unused);
nano_isr_sem_give (&testSema); nano_isr_sem_give (&testSema);
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -93,11 +93,11 @@ static void latencyTestIsr (void *unused)
*/ */
static void fiberInt (void) static void fiberInt (void)
{ {
setSwInterrupt (latencyTestIsr); setSwInterrupt (latencyTestIsr);
raiseIntFunc (); raiseIntFunc ();
fiber_yield (); fiber_yield ();
} }
/******************************************************************************* /*******************************************************************************
* *
@ -112,10 +112,10 @@ static void fiberInt (void)
*/ */
static void fiberWaiter (void) static void fiberWaiter (void)
{ {
nano_fiber_sem_take_wait (&testSema); nano_fiber_sem_take_wait (&testSema);
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -127,18 +127,18 @@ static void fiberWaiter (void)
*/ */
int nanoIntToFiberSem (void) int nanoIntToFiberSem (void)
{ {
PRINT_FORMAT (" 3- Measure time from ISR to executing a different fiber" PRINT_FORMAT (" 3- Measure time from ISR to executing a different fiber"
" (rescheduled)"); " (rescheduled)");
nano_sem_init (&testSema); nano_sem_init (&testSema);
TICK_SYNCH (); TICK_SYNCH ();
task_fiber_start (&waiterStack[0], STACKSIZE, 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, 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", 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; return 0;
} }

View file

@ -39,7 +39,7 @@
static inline void timestamp_serialize(void) static inline void timestamp_serialize(void)
{ {
__asm__ __volatile__ (/* serialize */ __asm__ __volatile__ (/* serialize */
"xorl %%eax,%%eax;\n\t" "xorl %%eax,%%eax;\n\t"
"cpuid;\n\t" "cpuid;\n\t"
: :

View file

@ -85,29 +85,29 @@ typedef int64_t TICK_TYPE;
extern uint32_t tm_off; extern uint32_t tm_off;
static inline uint32_t TIME_STAMP_DELTA_GET (uint32_t ts) static inline uint32_t TIME_STAMP_DELTA_GET (uint32_t ts)
{ {
uint32_t t; uint32_t t;
/* serialize so OS_GET_TIME() is not reordered */ /* serialize so OS_GET_TIME() is not reordered */
timestamp_serialize(); timestamp_serialize();
t = OS_GET_TIME (); t = OS_GET_TIME ();
uint32_t res = (t >= ts)? (t - ts): (ULONG_MAX - ts + t); uint32_t res = (t >= ts)? (t - ts): (ULONG_MAX - ts + t);
if (ts > 0) if (ts > 0)
res -= tm_off; res -= tm_off;
return res; return res;
} }
/* /*
* Routine initializes the benchmark timing measurement * Routine initializes the benchmark timing measurement
* The function sets up the global variable tm_off * The function sets up the global variable tm_off
*/ */
static inline void bench_test_init (void) static inline void bench_test_init (void)
{ {
uint32_t t = OS_GET_TIME (); uint32_t t = OS_GET_TIME ();
tm_off = OS_GET_TIME () - t; tm_off = OS_GET_TIME () - t;
} }
#if defined (CONFIG_MICROKERNEL) && defined (KERNEL) #if defined (CONFIG_MICROKERNEL) && defined (KERNEL)
@ -127,23 +127,23 @@ static TICK_TYPE tCheck;
* Functions modify the tCheck global variable. * Functions modify the tCheck global variable.
*/ */
static inline void bench_test_start (void) static inline void bench_test_start (void)
{ {
tCheck = 0; 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 (); TICK_SYNCH ();
tCheck = TICK_GET(&tCheck); tCheck = TICK_GET(&tCheck);
} }
/* returns 0 if the number of ticks is valid and -1 if not */ /* returns 0 if the number of ticks is valid and -1 if not */
static inline int bench_test_end (void) static inline int bench_test_end (void)
{ {
tCheck = TICK_GET(&tCheck); tCheck = TICK_GET(&tCheck);
if (tCheck > BENCH_MAX_TICKS) if (tCheck > BENCH_MAX_TICKS)
return -1; return -1;
else else
return 0; return 0;
} }
/* /*
* Returns -1 if number of ticks cause high precision timer counter * Returns -1 if number of ticks cause high precision timer counter
@ -152,12 +152,12 @@ static inline int bench_test_end (void)
* results or is it completely invalid * results or is it completely invalid
*/ */
static inline int high_timer_overflow (void) static inline int high_timer_overflow (void)
{ {
if (tCheck >= (UINT_MAX / sys_clock_hw_cycles_per_tick)) if (tCheck >= (UINT_MAX / sys_clock_hw_cycles_per_tick))
return -1; return -1;
else else
return 0; return 0;
} }
#endif /* CONFIG_NANOKERNEL || CONFIG_MICROKERNEL */ #endif /* CONFIG_NANOKERNEL || CONFIG_MICROKERNEL */
#endif /* _TIMESTAMP_H_ */ #endif /* _TIMESTAMP_H_ */

View file

@ -73,13 +73,13 @@ char tmpString[TMP_STRING_SIZE];
*/ */
int initSwInterrupt (ptestIsr pIsrHdlr) int initSwInterrupt (ptestIsr pIsrHdlr)
{ {
vector = irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, pIsrHdlr, vector = irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, pIsrHdlr,
(void *) 0, isrLatencyHandlerStub); (void *) 0, isrLatencyHandlerStub);
pcurrIsrFunc = pIsrHdlr; pcurrIsrFunc = pIsrHdlr;
return vector; return vector;
} }
/******************************************************************************* /*******************************************************************************
* *
@ -95,10 +95,10 @@ int initSwInterrupt (ptestIsr pIsrHdlr)
*/ */
void setSwInterrupt (ptestIsr pIsrHdlr) void setSwInterrupt (ptestIsr pIsrHdlr)
{ {
irq_handler_set (vector, pcurrIsrFunc, pIsrHdlr, (void *)0); irq_handler_set (vector, pcurrIsrFunc, pIsrHdlr, (void *)0);
pcurrIsrFunc = pIsrHdlr; pcurrIsrFunc = pIsrHdlr;
} }
/******************************************************************************* /*******************************************************************************
* *
@ -114,6 +114,6 @@ void setSwInterrupt (ptestIsr pIsrHdlr)
* \NOMANUAL * \NOMANUAL
*/ */
void raiseIntFunc (void) void raiseIntFunc (void)
{ {
raiseInt(vector); raiseInt(vector);
} }

View file

@ -52,12 +52,12 @@ extern int errorCount;
#define PRINTF(fmt, ...) printf (fmt, ##__VA_ARGS__) #define PRINTF(fmt, ...) printf (fmt, ##__VA_ARGS__)
#define PRINT_FORMAT(fmt, ...) \ #define PRINT_FORMAT(fmt, ...) \
do \ do \
{ \ { \
snprintf (tmpString, TMP_STRING_SIZE, fmt, ##__VA_ARGS__); \ snprintf (tmpString, TMP_STRING_SIZE, fmt, ##__VA_ARGS__); \
PRINTF ("|%-77s|\n", tmpString); \ PRINTF ("|%-77s|\n", tmpString); \
} \ } \
while (0) while (0)
/******************************************************************************* /*******************************************************************************
* *
@ -69,34 +69,34 @@ extern int errorCount;
*/ */
static inline void printDashLine (void) static inline void printDashLine (void)
{ {
PRINTF ("|-----------------------------------------------------------------" PRINTF ("|-----------------------------------------------------------------"
"------------|\n"); "------------|\n");
} }
#define PRINT_END_BANNER() \ #define PRINT_END_BANNER() \
PRINTF ("| E N D "\ PRINTF ("| E N D "\
" |\n"); \ " |\n"); \
printDashLine (); printDashLine ();
#define PRINT_NANO_BANNER() \ #define PRINT_NANO_BANNER() \
printDashLine (); \ printDashLine (); \
PRINTF ("| VxMicro Nanokernel Latency Benchmark "\ PRINTF ("| VxMicro Nanokernel Latency Benchmark "\
" |\n"); \ " |\n"); \
printDashLine (); printDashLine ();
#define PRINT_MICRO_BANNER() \ #define PRINT_MICRO_BANNER() \
printDashLine (); \ printDashLine (); \
PRINTF ("| VxMicro Microkernel Latency Benchmark "\ PRINTF ("| VxMicro Microkernel Latency Benchmark "\
" |\n"); \ " |\n"); \
printDashLine (); printDashLine ();
#define PRINT_TIME_BANNER() \ #define PRINT_TIME_BANNER() \
PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", SYS_CLOCK_HW_CYCLES_TO_NS(1));\ PRINT_FORMAT(" tcs = timer clock cycles: 1 tcs is %lu nsec", SYS_CLOCK_HW_CYCLES_TO_NS(1));\
printDashLine (); printDashLine ();
#define PRINT_OVERFLOW_ERROR() \ #define PRINT_OVERFLOW_ERROR() \
PRINT_FORMAT (" Error: tick occured") PRINT_FORMAT (" Error: tick occured")
#else #else
#error PRINTK needs to be enabled in VxMicro configuration #error PRINTK needs to be enabled in VxMicro configuration

View file

@ -88,28 +88,28 @@ static char pStack[FIBER_STACK_SIZE];
/* pointer array ensures specified functions are linked into the image */ /* pointer array ensures specified functions are linked into the image */
volatile pfunc func_array[] = { volatile pfunc func_array[] = {
/* nano timer functions */ /* nano timer functions */
(pfunc)nano_timer_init, (pfunc)nano_timer_init,
(pfunc)nano_fiber_timer_start, (pfunc)nano_fiber_timer_start,
(pfunc)nano_fiber_timer_wait, (pfunc)nano_fiber_timer_wait,
/* nano semaphore functions */ /* nano semaphore functions */
(pfunc)nano_sem_init, (pfunc)nano_sem_init,
(pfunc)nano_fiber_sem_take_wait, (pfunc)nano_fiber_sem_take_wait,
(pfunc)nano_fiber_sem_give, (pfunc)nano_fiber_sem_give,
#ifdef TEST_max #ifdef TEST_max
/* nano LIFO functions */ /* nano LIFO functions */
(pfunc)nano_lifo_init, (pfunc)nano_lifo_init,
(pfunc)nano_fiber_lifo_put, (pfunc)nano_fiber_lifo_put,
(pfunc)nano_fiber_lifo_get, (pfunc)nano_fiber_lifo_get,
/* nano stack functions */ /* nano stack functions */
(pfunc)nano_stack_init, (pfunc)nano_stack_init,
(pfunc)nano_fiber_stack_push, (pfunc)nano_fiber_stack_push,
(pfunc)nano_fiber_stack_pop, (pfunc)nano_fiber_stack_pop,
/* nano FIFO functions */ /* nano FIFO functions */
(pfunc)nano_fifo_init, (pfunc)nano_fifo_init,
(pfunc)nano_fiber_fifo_put, (pfunc)nano_fiber_fifo_put,
(pfunc)nano_fiber_fifo_get, (pfunc)nano_fiber_fifo_get,
#endif /* TEST_max */ #endif /* TEST_max */
}; };
/******************************************************************************* /*******************************************************************************
* *
@ -119,9 +119,9 @@ volatile pfunc func_array[] = {
*/ */
void dummyIsr (void *unused) void dummyIsr (void *unused)
{ {
ARG_UNUSED (unused); ARG_UNUSED (unused);
} }
#ifdef TEST_reg #ifdef TEST_reg
/******************************************************************************* /*******************************************************************************
@ -136,13 +136,13 @@ void dummyIsr (void *unused)
*/ */
static void isrDummyIntStub (void *unused) static void isrDummyIntStub (void *unused)
{ {
ARG_UNUSED (unused); ARG_UNUSED (unused);
isr_dummy(); isr_dummy();
CODE_UNREACHABLE; CODE_UNREACHABLE;
} }
#endif /* TEST_reg */ #endif /* TEST_reg */
/******************************************************************************* /*******************************************************************************
@ -153,19 +153,19 @@ static void isrDummyIntStub (void *unused)
*/ */
static void fiberEntry static void fiberEntry
( (
int message, /* message to be printed */ int message, /* message to be printed */
int arg1 /* unused */ int arg1 /* unused */
) )
{ {
ARG_UNUSED (arg1); ARG_UNUSED (arg1);
#ifdef TEST_max #ifdef TEST_max
printf ((char *)message); printf ((char *)message);
#else #else
printk ((char *)message); printk ((char *)message);
#endif /* TEST_max */ #endif /* TEST_max */
} }
#endif /* !TEST_min */ #endif /* !TEST_min */
@ -180,19 +180,19 @@ static void fiberEntry
*/ */
void main (void) void main (void)
{ {
#ifdef TEST_max #ifdef TEST_max
/* dynamically link in dummy ISR */ /* dynamically link in dummy ISR */
irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr, irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, dummyIsr,
(void *) 0, isrDummyHandlerStub); (void *) 0, isrDummyHandlerStub);
#endif /* TEST_max */ #endif /* TEST_max */
#ifndef TEST_min #ifndef TEST_min
/* start a trivial fiber */ /* start a trivial fiber */
task_fiber_start (pStack, FIBER_STACK_SIZE, fiberEntry, (int) MESSAGE, task_fiber_start (pStack, FIBER_STACK_SIZE, fiberEntry, (int) MESSAGE,
(int) func_array, 10, 0); (int) func_array, 10, 0);
#endif /* !TEST_min */ #endif /* !TEST_min */
while (1) { while (1) {
i++; i++;
} }
} }

View file

@ -47,10 +47,10 @@ static struct nano_fifo nanoFifo_sync; /* for synchronization */
*/ */
void lifo_test_init (void) void lifo_test_init (void)
{ {
nano_lifo_init (&nanoLifo1); nano_lifo_init (&nanoLifo1);
nano_lifo_init (&nanoLifo2); nano_lifo_init (&nanoLifo2);
} }
/******************************************************************************* /*******************************************************************************
@ -63,18 +63,18 @@ void lifo_test_init (void)
*/ */
void lifo_fiber1 ( void lifo_fiber1 (
int par1, /* ignored parameter */ int par1, /* ignored parameter */
int par2 /* number of test loops */ int par2 /* number of test loops */
) )
{ {
int i; int i;
int element_a[2]; int element_a[2];
int element_b[2]; int element_b[2];
int * pelement; int * pelement;
ARG_UNUSED (par1); ARG_UNUSED (par1);
for (i = 0; i < par2 / 2; i++) { for (i = 0; i < par2 / 2; i++) {
pelement = (int *) nano_fiber_lifo_get_wait (&nanoLifo1); pelement = (int *) nano_fiber_lifo_get_wait (&nanoLifo1);
if (pelement[1] != 2 * i) if (pelement[1] != 2 * i)
break; break;
@ -87,8 +87,8 @@ void lifo_fiber1 (
nano_fiber_lifo_put (&nanoLifo2, element_b); 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); nano_fiber_fifo_get_wait (&nanoFifo_sync);
} }
/******************************************************************************* /*******************************************************************************
@ -101,16 +101,16 @@ void lifo_fiber1 (
*/ */
void lifo_fiber2 ( void lifo_fiber2 (
int par1, /* address of the counter */ int par1, /* address of the counter */
int par2 /* number of test cycles */ int par2 /* number of test cycles */
) )
{ {
int i; int i;
int element[2]; int element[2];
int * pelement; int * pelement;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
element[1] = i; element[1] = i;
nano_fiber_lifo_put (&nanoLifo1, element); nano_fiber_lifo_put (&nanoLifo1, element);
pelement = (int *) nano_fiber_lifo_get_wait (&nanoLifo2); pelement = (int *) nano_fiber_lifo_get_wait (&nanoLifo2);
@ -119,8 +119,8 @@ void lifo_fiber2 (
(*pcounter)++; (*pcounter)++;
} }
/* wait till it is safe to end: */ /* wait till it is safe to end: */
nano_fiber_fifo_get_wait (&nanoFifo_sync); nano_fiber_fifo_get_wait (&nanoFifo_sync);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -132,16 +132,16 @@ void lifo_fiber2 (
*/ */
void lifo_fiber3 ( void lifo_fiber3 (
int par1, /* address of the counter */ int par1, /* address of the counter */
int par2 /* number of test loops */ int par2 /* number of test loops */
) )
{ {
int i; int i;
int element[2]; int element[2];
int * pelement; int * pelement;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
element[1] = i; element[1] = i;
nano_fiber_lifo_put (&nanoLifo1, element); nano_fiber_lifo_put (&nanoLifo1, element);
while (NULL == (pelement = (int *) nano_fiber_lifo_get (&nanoLifo2))) while (NULL == (pelement = (int *) nano_fiber_lifo_get (&nanoLifo2)))
@ -151,8 +151,8 @@ void lifo_fiber3 (
(*pcounter)++; (*pcounter)++;
} }
/* wait till it is safe to end: */ /* wait till it is safe to end: */
nano_fiber_fifo_get_wait (&nanoFifo_sync); nano_fiber_fifo_get_wait (&nanoFifo_sync);
} }
/******************************************************************************* /*******************************************************************************
* *
@ -164,84 +164,84 @@ void lifo_fiber3 (
*/ */
int lifo_test (void) int lifo_test (void)
{ {
uint32_t t; uint32_t t;
int i = 0; int i = 0;
int return_value = 0; int return_value = 0;
int element[2]; int element[2];
int j; int j;
nano_fifo_init (&nanoFifo_sync); nano_fifo_init (&nanoFifo_sync);
/* test get wait & put fiber functions */ /* test get wait & put fiber functions */
fprintf (output_file, sz_test_case_fmt, 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, fprintf (output_file, sz_description,
"testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," "testing 'nano_lifo_init','nano_fiber_lifo_get_wait',"
" 'nano_fiber_lifo_put' functions;"); " 'nano_fiber_lifo_put' functions;");
printf (sz_test_start_fmt, "'nano_fiber_lifo_get_wait'"); printf (sz_test_start_fmt, "'nano_fiber_lifo_get_wait'");
lifo_test_init (); lifo_test_init ();
t = BENCH_START (); t = BENCH_START ();
task_fiber_start (fiber_stack1, STACK_SIZE, lifo_fiber1, 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_fiber2, (int) &i, 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); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i, t); return_value += check_result (i, t);
/* fiber contexts have done their job, they can stop now safely: */ /* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
nano_task_fifo_put (&nanoFifo_sync, (void *) element); 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, fprintf (output_file, sz_test_case_fmt,
"LIFO channel - 'nano_fiber_lifo_get'"); "LIFO channel - 'nano_fiber_lifo_get'");
fprintf (output_file, sz_description, fprintf (output_file, sz_description,
"testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," "testing 'nano_lifo_init','nano_fiber_lifo_get_wait',"
" 'nano_fiber_lifo_get',\n"); " 'nano_fiber_lifo_get',\n");
fprintf (output_file, 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'"); printf (sz_test_start_fmt, "'nano_fiber_lifo_get'");
lifo_test_init (); lifo_test_init ();
t = BENCH_START (); t = BENCH_START ();
i = 0; i = 0;
task_fiber_start (fiber_stack1, STACK_SIZE, lifo_fiber1, 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, 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); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i, t); return_value += check_result (i, t);
/* fiber contexts have done their job, they can stop now safely: */ /* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
nano_task_fifo_put (&nanoFifo_sync, (void *) element); 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, 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, fprintf (output_file, sz_description,
"testing 'nano_lifo_init','nano_fiber_lifo_get_wait'," "testing 'nano_lifo_init','nano_fiber_lifo_get_wait',"
" 'nano_fiber_lifo_put',\n"); " 'nano_fiber_lifo_put',\n");
fprintf (output_file, "\t'nano_task_lifo_get_wait', 'nano_task_lifo_put' functions;"); fprintf (output_file, "\t'nano_task_lifo_get_wait', 'nano_task_lifo_put' functions;");
printf (sz_test_start_fmt, "'nano_task_lifo_get_wait'"); printf (sz_test_start_fmt, "'nano_task_lifo_get_wait'");
lifo_test_init (); lifo_test_init ();
t = BENCH_START (); t = BENCH_START ();
task_fiber_start (fiber_stack1, STACK_SIZE, lifo_fiber1, 0, 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++) { for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {
int element[2]; int element[2];
int * pelement; int * pelement;
element[1] = 2 * i; element[1] = 2 * i;
@ -257,13 +257,13 @@ int lifo_test (void)
break; break;
} }
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i * 2, t); return_value += check_result (i * 2, t);
/* fiber contexts have done their job, they can stop now safely: */ /* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
nano_task_fifo_put (&nanoFifo_sync, (void *) element); nano_task_fifo_put (&nanoFifo_sync, (void *) element);
return return_value; return return_value;
} }

View file

@ -48,10 +48,10 @@ static struct nano_fifo nanoFifo_sync; /* for synchronization */
*/ */
void fifo_test_init (void) void fifo_test_init (void)
{ {
nano_fifo_init (&nanoFifo1); nano_fifo_init (&nanoFifo1);
nano_fifo_init (&nanoFifo2); nano_fifo_init (&nanoFifo2);
} }
/******************************************************************************* /*******************************************************************************
@ -64,16 +64,16 @@ void fifo_test_init (void)
*/ */
void fifo_fiber1 ( void fifo_fiber1 (
int par1, /* ignored parameter */ int par1, /* ignored parameter */
int par2 /* number of test loops */ int par2 /* number of test loops */
) )
{ {
int i; int i;
int element[2]; int element[2];
int * pelement; int * pelement;
ARG_UNUSED (par1); ARG_UNUSED (par1);
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
pelement = (int *) nano_fiber_fifo_get_wait (&nanoFifo1); pelement = (int *) nano_fiber_fifo_get_wait (&nanoFifo1);
if (pelement[1] != i) if (pelement[1] != i)
break; break;
@ -81,8 +81,8 @@ void fifo_fiber1 (
nano_fiber_fifo_put (&nanoFifo2, element); 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); nano_fiber_fifo_get_wait (&nanoFifo_sync);
} }
/******************************************************************************* /*******************************************************************************
@ -95,16 +95,16 @@ void fifo_fiber1 (
*/ */
void fifo_fiber2 ( void fifo_fiber2 (
int par1, /* address of the counter */ int par1, /* address of the counter */
int par2 /* number of test cycles */ int par2 /* number of test cycles */
) )
{ {
int i; int i;
int element[2]; int element[2];
int * pelement; int * pelement;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
element[1] = i; element[1] = i;
nano_fiber_fifo_put (&nanoFifo1, element); nano_fiber_fifo_put (&nanoFifo1, element);
pelement = (int *) nano_fiber_fifo_get_wait (&nanoFifo2); pelement = (int *) nano_fiber_fifo_get_wait (&nanoFifo2);
@ -113,8 +113,8 @@ void fifo_fiber2 (
(*pcounter)++; (*pcounter)++;
} }
/* wait till it is safe to end: */ /* wait till it is safe to end: */
nano_fiber_fifo_get_wait (&nanoFifo_sync); nano_fiber_fifo_get_wait (&nanoFifo_sync);
} }
/******************************************************************************* /*******************************************************************************
@ -127,16 +127,16 @@ void fifo_fiber2 (
*/ */
void fifo_fiber3 ( void fifo_fiber3 (
int par1, /* address of the counter */ int par1, /* address of the counter */
int par2 /* number of test cycles */ int par2 /* number of test cycles */
) )
{ {
int i; int i;
int element[2]; int element[2];
int * pelement; int * pelement;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
element[1] = i; element[1] = i;
nano_fiber_fifo_put (&nanoFifo1, element); nano_fiber_fifo_put (&nanoFifo1, element);
while (NULL == (pelement = (int *) nano_fiber_fifo_get (&nanoFifo2))) while (NULL == (pelement = (int *) nano_fiber_fifo_get (&nanoFifo2)))
@ -146,8 +146,8 @@ void fifo_fiber3 (
(*pcounter)++; (*pcounter)++;
} }
/* wait till it is safe to end: */ /* wait till it is safe to end: */
nano_fiber_fifo_get_wait (&nanoFifo_sync); nano_fiber_fifo_get_wait (&nanoFifo_sync);
} }
/******************************************************************************* /*******************************************************************************
@ -160,87 +160,87 @@ void fifo_fiber3 (
*/ */
int fifo_test (void) int fifo_test (void)
{ {
uint32_t t; uint32_t t;
int i = 0; int i = 0;
int return_value = 0; int return_value = 0;
int element[2]; int element[2];
int j; int j;
nano_fifo_init (&nanoFifo_sync); nano_fifo_init (&nanoFifo_sync);
/* test get wait & put fiber functions */ /* test get wait & put fiber functions */
fprintf (output_file, sz_test_case_fmt, 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, fprintf (output_file, sz_description,
"testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," "testing 'nano_fifo_init','nano_fiber_fifo_get_wait',"
" 'nano_fiber_fifo_put' functions;"); " 'nano_fiber_fifo_put' functions;");
printf (sz_test_start_fmt, "'nano_fiber_fifo_get_wait'"); printf (sz_test_start_fmt, "'nano_fiber_fifo_get_wait'");
fifo_test_init (); fifo_test_init ();
t = BENCH_START (); t = BENCH_START ();
task_fiber_start (fiber_stack1, STACK_SIZE, fifo_fiber1, 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_fiber2, (int) &i, 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); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i, t); return_value += check_result (i, t);
/* fiber contexts have done their job, they can stop now safely: */ /* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
nano_task_fifo_put (&nanoFifo_sync, (void *) element); 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, fprintf (output_file, sz_test_case_fmt,
"FIFO channel - 'nano_fiber_fifo_get'"); "FIFO channel - 'nano_fiber_fifo_get'");
fprintf (output_file, sz_description, fprintf (output_file, sz_description,
"testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," "testing 'nano_fifo_init','nano_fiber_fifo_get_wait',"
" 'nano_fiber_fifo_get',\n"); " 'nano_fiber_fifo_get',\n");
fprintf (output_file, 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'"); printf (sz_test_start_fmt, "'nano_fiber_fifo_get'");
fifo_test_init (); fifo_test_init ();
t = BENCH_START (); t = BENCH_START ();
i = 0; i = 0;
task_fiber_start (fiber_stack1, STACK_SIZE, fifo_fiber1, 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, 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); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i, t); return_value += check_result (i, t);
/* fiber contexts have done their job, they can stop now safely: */ /* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
nano_task_fifo_put (&nanoFifo_sync, (void *) element); 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, 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, fprintf (output_file, sz_description,
"testing 'nano_fifo_init','nano_fiber_fifo_get_wait'," "testing 'nano_fifo_init','nano_fiber_fifo_get_wait',"
" 'nano_fiber_fifo_put',\n"); " 'nano_fiber_fifo_put',\n");
fprintf (output_file, 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'"); printf (sz_test_start_fmt, "'nano_task_fifo_get_wait'");
fifo_test_init (); fifo_test_init ();
t = BENCH_START (); t = BENCH_START ();
task_fiber_start (fiber_stack1, STACK_SIZE, fifo_fiber1, 0, 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, 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++) { for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {
int element[2]; int element[2];
int * pelement; int * pelement;
element[1] = i; element[1] = i;
@ -255,13 +255,13 @@ int fifo_test (void)
if (pelement[1] != i) if (pelement[1] != i)
break; break;
} }
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i * 2, t); return_value += check_result (i * 2, t);
/* fiber contexts have done their job, they can stop now safely: */ /* fiber contexts have done their job, they can stop now safely: */
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
nano_task_fifo_put (&nanoFifo_sync, (void *) element); nano_task_fifo_put (&nanoFifo_sync, (void *) element);
return return_value; return return_value;
} }

View file

@ -45,10 +45,10 @@ struct nano_sem nanoSem2;
*/ */
void sema_test_init (void) void sema_test_init (void)
{ {
nano_sem_init (&nanoSem1); nano_sem_init (&nanoSem1);
nano_sem_init (&nanoSem2); nano_sem_init (&nanoSem2);
} }
/******************************************************************************* /*******************************************************************************
@ -61,19 +61,19 @@ void sema_test_init (void)
*/ */
void sema_fiber1 ( void sema_fiber1 (
int par1, /* ignored parameter */ int par1, /* ignored parameter */
int par2 /* number of test loops */ int par2 /* number of test loops */
) )
{ {
int i; int i;
ARG_UNUSED (par1); ARG_UNUSED (par1);
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
nano_fiber_sem_take_wait (&nanoSem1); nano_fiber_sem_take_wait (&nanoSem1);
nano_fiber_sem_give (&nanoSem2); nano_fiber_sem_give (&nanoSem2);
} }
} }
/******************************************************************************* /*******************************************************************************
@ -86,19 +86,19 @@ void sema_fiber1 (
*/ */
void sema_fiber2 ( void sema_fiber2 (
int par1, /* address of the counter */ int par1, /* address of the counter */
int par2 /* number of test cycles */ int par2 /* number of test cycles */
) )
{ {
int i; int i;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
nano_fiber_sem_give (&nanoSem1); nano_fiber_sem_give (&nanoSem1);
nano_fiber_sem_take_wait (&nanoSem2); nano_fiber_sem_take_wait (&nanoSem2);
(*pcounter)++; (*pcounter)++;
} }
} }
/******************************************************************************* /*******************************************************************************
* *
@ -110,20 +110,20 @@ void sema_fiber2 (
*/ */
void sema_fiber3 ( void sema_fiber3 (
int par1, /* address of the counter */ int par1, /* address of the counter */
int par2 /* number of test cycles */ int par2 /* number of test cycles */
) )
{ {
int i; int i;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
nano_fiber_sem_give (&nanoSem1); nano_fiber_sem_give (&nanoSem1);
while (!nano_fiber_sem_take (&nanoSem2)) while (!nano_fiber_sem_take (&nanoSem2))
fiber_yield (); fiber_yield ();
(*pcounter)++; (*pcounter)++;
} }
} }
/******************************************************************************* /*******************************************************************************
@ -136,75 +136,75 @@ void sema_fiber3 (
*/ */
int sema_test (void) int sema_test (void)
{ {
uint32_t t; uint32_t t;
int i = 0; int i = 0;
int return_value = 0; int return_value = 0;
fprintf (output_file, sz_test_case_fmt, 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, fprintf (output_file, sz_description,
"testing 'nano_sem_init','nano_fiber_sem_take_wait'," "testing 'nano_sem_init','nano_fiber_sem_take_wait',"
" 'nano_fiber_sem_give' functions;"); " 'nano_fiber_sem_give' functions;");
printf (sz_test_start_fmt, "'nano_fiber_sem_take_wait'"); printf (sz_test_start_fmt, "'nano_fiber_sem_take_wait'");
sema_test_init (); sema_test_init ();
t = BENCH_START (); t = BENCH_START ();
task_fiber_start (fiber_stack1, STACK_SIZE, sema_fiber1, 0, 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, 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); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i, t); return_value += check_result (i, t);
fprintf (output_file, sz_test_case_fmt, fprintf (output_file, sz_test_case_fmt,
"Semaphore channel - 'nano_fiber_sem_take'"); "Semaphore channel - 'nano_fiber_sem_take'");
fprintf (output_file, sz_description, 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;"); fprintf (output_file, "\t'nano_fiber_sem_give' functions;");
printf (sz_test_start_fmt, "'nano_fiber_sem_take'"); printf (sz_test_start_fmt, "'nano_fiber_sem_take'");
sema_test_init (); sema_test_init ();
i = 0; i = 0;
t = BENCH_START (); t = BENCH_START ();
task_fiber_start (fiber_stack1, STACK_SIZE, sema_fiber1, 0, 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, 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); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i, t); return_value += check_result (i, t);
fprintf (output_file, sz_test_case_fmt, 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, fprintf (output_file, sz_description,
"testing 'nano_sem_init','nano_fiber_sem_take_wait'," "testing 'nano_sem_init','nano_fiber_sem_take_wait',"
" 'nano_fiber_sem_give',\n"); " 'nano_fiber_sem_give',\n");
fprintf (output_file, 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'"); printf (sz_test_start_fmt, "'nano_task_sem_take_wait'");
sema_test_init (); sema_test_init ();
t = BENCH_START (); t = BENCH_START ();
task_fiber_start (fiber_stack1, STACK_SIZE, sema_fiber1, 0, 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++) { for (i = 0; i < NUMBER_OF_LOOPS; i++) {
nano_task_sem_give (&nanoSem1); nano_task_sem_give (&nanoSem1);
nano_task_sem_take_wait (&nanoSem2); nano_task_sem_take_wait (&nanoSem2);
} }
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i, t); return_value += check_result (i, t);
return return_value; return return_value;
} }

View file

@ -48,10 +48,10 @@ uint32_t stack2[2];
*/ */
void stack_test_init (void) void stack_test_init (void)
{ {
nano_stack_init (&nanoChannel1, stack1); nano_stack_init (&nanoChannel1, stack1);
nano_stack_init (&nanoChannel2, stack2); nano_stack_init (&nanoChannel2, stack2);
} }
/******************************************************************************* /*******************************************************************************
@ -64,16 +64,16 @@ void stack_test_init (void)
*/ */
void stack_fiber1 ( void stack_fiber1 (
int par1, /* ignored parameter */ int par1, /* ignored parameter */
int par2 /* number of test loops */ int par2 /* number of test loops */
) )
{ {
int i; int i;
uint32_t data; uint32_t data;
ARG_UNUSED (par1); ARG_UNUSED (par1);
for (i = 0; i < par2 / 2; i++) { for (i = 0; i < par2 / 2; i++) {
data = nano_fiber_stack_pop_wait (&nanoChannel1); data = nano_fiber_stack_pop_wait (&nanoChannel1);
if (data != 2 * i) if (data != 2 * i)
break; break;
@ -85,7 +85,7 @@ void stack_fiber1 (
data = 2 * i + 1; data = 2 * i + 1;
nano_fiber_stack_push (&nanoChannel2, data); nano_fiber_stack_push (&nanoChannel2, data);
} }
} }
/******************************************************************************* /*******************************************************************************
@ -98,15 +98,15 @@ void stack_fiber1 (
*/ */
void stack_fiber2 ( void stack_fiber2 (
int par1, /* address of the counter */ int par1, /* address of the counter */
int par2 /* number of test cycles */ int par2 /* number of test cycles */
) )
{ {
int i; int i;
uint32_t data; uint32_t data;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
data = i; data = i;
nano_fiber_stack_push (&nanoChannel1, data); nano_fiber_stack_push (&nanoChannel1, data);
data = nano_fiber_stack_pop_wait (&nanoChannel2); data = nano_fiber_stack_pop_wait (&nanoChannel2);
@ -114,7 +114,7 @@ void stack_fiber2 (
break; break;
(*pcounter)++; (*pcounter)++;
} }
} }
/******************************************************************************* /*******************************************************************************
@ -127,15 +127,15 @@ void stack_fiber2 (
*/ */
void stack_fiber3 ( void stack_fiber3 (
int par1, /* address of the counter */ int par1, /* address of the counter */
int par2 /* number of test cycles */ int par2 /* number of test cycles */
) )
{ {
int i; int i;
uint32_t data; uint32_t data;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) { for (i = 0; i < par2; i++) {
data = i; data = i;
nano_fiber_stack_push (&nanoChannel1, data); nano_fiber_stack_push (&nanoChannel1, data);
data = 0xffffffff; data = 0xffffffff;
@ -145,7 +145,7 @@ void stack_fiber3 (
break; break;
(*pcounter)++; (*pcounter)++;
} }
} }
/******************************************************************************* /*******************************************************************************
@ -158,73 +158,73 @@ void stack_fiber3 (
*/ */
int stack_test (void) int stack_test (void)
{ {
uint32_t t; uint32_t t;
int i = 0; int i = 0;
int return_value = 0; int return_value = 0;
/* test get wait & put fiber functions */ /* test get wait & put fiber functions */
fprintf (output_file, sz_test_case_fmt, 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, fprintf (output_file, sz_description,
"testing 'nano_stack_init','nano_fiber_stack_pop_wait'," "testing 'nano_stack_init','nano_fiber_stack_pop_wait',"
" 'nano_fiber_stack_push' functions;"); " 'nano_fiber_stack_push' functions;");
printf (sz_test_start_fmt, "'nano_fiber_stack_pop_wait'"); printf (sz_test_start_fmt, "'nano_fiber_stack_pop_wait'");
stack_test_init (); stack_test_init ();
t = BENCH_START (); t = BENCH_START ();
task_fiber_start (fiber_stack1, STACK_SIZE, stack_fiber1, 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_fiber2, (int) &i, 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); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i, 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, fprintf (output_file, sz_test_case_fmt,
"Stack channel - 'nano_fiber_stack_pop'"); "Stack channel - 'nano_fiber_stack_pop'");
fprintf (output_file, sz_description, fprintf (output_file, sz_description,
"testing 'nano_stack_init','nano_fiber_stack_pop_wait'," "testing 'nano_stack_init','nano_fiber_stack_pop_wait',"
" 'nano_fiber_stack_pop',\n"); " 'nano_fiber_stack_pop',\n");
fprintf (output_file, 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'"); printf (sz_test_start_fmt, "'nano_fiber_stack_pop'");
stack_test_init (); stack_test_init ();
t = BENCH_START (); t = BENCH_START ();
i = 0; i = 0;
task_fiber_start (fiber_stack1, STACK_SIZE, stack_fiber1, 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, 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); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i, 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, 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, fprintf (output_file, sz_description,
"testing 'nano_stack_init','nano_fiber_stack_pop_wait'," "testing 'nano_stack_init','nano_fiber_stack_pop_wait',"
" 'nano_fiber_stack_push',\n"); " 'nano_fiber_stack_push',\n");
fprintf (output_file, 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'"); printf (sz_test_start_fmt, "'nano_task_stack_pop_wait'");
stack_test_init (); stack_test_init ();
t = BENCH_START (); t = BENCH_START ();
task_fiber_start (fiber_stack1, STACK_SIZE, stack_fiber1, 0, 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++) { for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {
uint32_t data; uint32_t data;
data = 2 * i; data = 2 * i;
nano_task_stack_push (&nanoChannel1, data); nano_task_stack_push (&nanoChannel1, data);
@ -239,9 +239,9 @@ int stack_test (void)
break; break;
} }
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);
return_value += check_result (i * 2, t); return_value += check_result (i * 2, t);
return return_value; return return_value;
} }

View file

@ -87,13 +87,13 @@ uint32_t tm_off;
* \NOMANUAL * \NOMANUAL
*/ */
void begin_test (void) void begin_test (void)
{ {
/* /*
Invoke bench_test_start in order to be able to use Invoke bench_test_start in order to be able to use
tCheck static variable. tCheck static variable.
*/ */
bench_test_start (); bench_test_start ();
} }
/******************************************************************************* /*******************************************************************************
* *
@ -105,37 +105,37 @@ void begin_test (void)
*/ */
int check_result ( int check_result (
int i, /* number of tests */ int i, /* number of tests */
uint32_t t /* time in ticks for the whole test */ uint32_t t /* time in ticks for the whole test */
) )
{ {
/* /*
bench_test_end checks tCheck static variable. bench_test_end checks tCheck static variable.
bench_test_start modifies it bench_test_start modifies it
*/ */
if (bench_test_end () != 0) { if (bench_test_end () != 0) {
fprintf (output_file, sz_case_result_fmt, sz_fail); fprintf (output_file, sz_case_result_fmt, sz_fail);
fprintf (output_file, sz_case_details_fmt, fprintf (output_file, sz_case_details_fmt,
"timer tick happened. Results are inaccurate"); "timer tick happened. Results are inaccurate");
fprintf (output_file, sz_case_end_fmt); fprintf (output_file, sz_case_end_fmt);
return 0; return 0;
} }
if (i != NUMBER_OF_LOOPS) { if (i != NUMBER_OF_LOOPS) {
fprintf (output_file, sz_case_result_fmt, sz_fail); fprintf (output_file, sz_case_result_fmt, sz_fail);
fprintf (output_file, sz_case_details_fmt, "loop counter = "); fprintf (output_file, sz_case_details_fmt, "loop counter = ");
fprintf (output_file, "%i !!!", i); fprintf (output_file, "%i !!!", i);
fprintf (output_file, sz_case_end_fmt); fprintf (output_file, sz_case_end_fmt);
return 0; return 0;
} }
fprintf (output_file, sz_case_result_fmt, sz_success); fprintf (output_file, sz_case_result_fmt, sz_success);
fprintf (output_file, sz_case_details_fmt, fprintf (output_file, sz_case_details_fmt,
"Average time for 1 iteration: "); "Average time for 1 iteration: ");
fprintf (output_file, sz_case_timing_fmt, 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); fprintf (output_file, sz_case_end_fmt);
return 1; return 1;
} }
/******************************************************************************* /*******************************************************************************
@ -149,7 +149,7 @@ int check_result (
int kbhit (void) int kbhit (void)
{ {
return 0; return 0;
} }
@ -163,16 +163,16 @@ int kbhit (void)
*/ */
void init_output ( void init_output (
int *continuously /* run test till the user presses the key */ int *continuously /* run test till the user presses the key */
) )
{ {
ARG_UNUSED (continuously); ARG_UNUSED (continuously);
/* /*
* send all printf and fprintf to console * send all printf and fprintf to console
*/ */
output_file = stdout; output_file = stdout;
} }
/******************************************************************************* /*******************************************************************************
@ -185,8 +185,8 @@ void init_output (
*/ */
void output_close (void) void output_close (void)
{ {
} }
/******************************************************************************* /*******************************************************************************
* *
@ -202,14 +202,14 @@ void SysKernelBench (void)
#else #else
void main (void) void main (void)
#endif #endif
{ {
int continuously = 0; int continuously = 0;
int test_result; int test_result;
init_output (&continuously); init_output (&continuously);
bench_test_init (); bench_test_init ();
do { do {
fprintf (output_file, sz_module_title_fmt, "Nanokernel API test"); fprintf (output_file, sz_module_title_fmt, "Nanokernel API test");
fprintf (output_file, sz_kernel_ver_fmt, kernel_version_get ()); fprintf (output_file, sz_kernel_ver_fmt, kernel_version_get ());
fprintf (output_file, fprintf (output_file,
@ -234,7 +234,7 @@ void main (void)
fprintf (output_file, sz_module_result_fmt, sz_fail); fprintf (output_file, sz_module_result_fmt, sz_fail);
} }
while (continuously && !kbhit ()); while (continuously && !kbhit ());
output_close (); output_close ();
} }

View file

@ -74,12 +74,12 @@ int stack_test (void);
void begin_test (void); void begin_test (void);
static inline uint32_t BENCH_START (void) static inline uint32_t BENCH_START (void)
{ {
uint32_t et; uint32_t et;
begin_test (); begin_test ();
et = TIME_STAMP_DELTA_GET (0); et = TIME_STAMP_DELTA_GET (0);
return et; return et;
} }
#endif /* SYSKERNEK_H */ #endif /* SYSKERNEK_H */