nano_fifo: Simplify nano_xxx_fifo_get() API family
Changes the nanokernel FIFO API so that the timeout parameter must be specified when invoking nano_isr_fifo_get(), nano_fiber_fifo_get(), nano_task_fifo_get() and nano_fifo_get(). This obsoletes the following APIs: nano_fiber_fifo_get_wait() nano_fiber_fifo_get_wait_timeout() nano_task_fifo_get_wait() nano_task_fifo_get_wait_timeout() nano_fifo_get_wait() nano_fifo_get_wait_timeout() Change-Id: Icbd2909292f1ced0bad8a70a075478536a141ef2 Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
This commit is contained in:
parent
a6b20d4c04
commit
cd6db374de
26 changed files with 189 additions and 396 deletions
|
@ -140,7 +140,7 @@ SECTION_FUNC(TEXT, nano_cpu_idle)
|
||||||
*
|
*
|
||||||
* This function is utilized by the nanokernel object "wait" APIs for tasks,
|
* This function is utilized by the nanokernel object "wait" APIs for tasks,
|
||||||
* e.g. nano_task_lifo_get_wait(), nano_task_sem_take_wait(),
|
* e.g. nano_task_lifo_get_wait(), nano_task_sem_take_wait(),
|
||||||
* nano_task_stack_pop_wait(), and nano_task_fifo_get_wait().
|
* nano_task_stack_pop_wait(), and nano_task_fifo_get().
|
||||||
*
|
*
|
||||||
* INTERNAL
|
* INTERNAL
|
||||||
* The requirements for nano_cpu_atomic_idle() are as follows:
|
* The requirements for nano_cpu_atomic_idle() are as follows:
|
||||||
|
|
|
@ -72,7 +72,7 @@ void nano_cpu_idle(void)
|
||||||
*
|
*
|
||||||
* This function is utilized by the nanokernel object "wait" APIs for tasks,
|
* This function is utilized by the nanokernel object "wait" APIs for tasks,
|
||||||
* e.g. nano_task_lifo_get_wait(), nano_task_sem_take_wait(),
|
* e.g. nano_task_lifo_get_wait(), nano_task_sem_take_wait(),
|
||||||
* nano_task_stack_pop_wait(), and nano_task_fifo_get_wait().
|
* nano_task_stack_pop_wait(), and nano_task_fifo_get().
|
||||||
*
|
*
|
||||||
* INTERNAL
|
* INTERNAL
|
||||||
* The requirements for nano_cpu_atomic_idle() are as follows:
|
* The requirements for nano_cpu_atomic_idle() are as follows:
|
||||||
|
|
|
@ -116,7 +116,7 @@ of data items to multiple consumer fibers, if desired.
|
||||||
ARG_UNUSED(unused2);
|
ARG_UNUSED(unused2);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
rx_data = nano_fiber_fifo_get_wait(&signal_fifo);
|
rx_data = nano_fiber_fifo_get_wait(&signal_fifo, TICKS_NONE);
|
||||||
|
|
||||||
/* process FIFO data */
|
/* process FIFO data */
|
||||||
...
|
...
|
||||||
|
@ -137,14 +137,5 @@ The following APIs for a nanokernel FIFO are provided by :file:`nanokernel.h`:
|
||||||
|
|
||||||
:cpp:func:`nano_task_fifo_get()`, :cpp:func:`nano_fiber_fifo_get()`,
|
:cpp:func:`nano_task_fifo_get()`, :cpp:func:`nano_fiber_fifo_get()`,
|
||||||
:cpp:func:`nano_isr_fifo_get()`, :cpp:func:`nano_fifo_get()`
|
:cpp:func:`nano_isr_fifo_get()`, :cpp:func:`nano_fifo_get()`
|
||||||
Remove an item from a FIFO, or fails and continues if it is empty.
|
|
||||||
|
|
||||||
:cpp:func:`nano_task_fifo_get_wait()`, :cpp:func:`nano_fiber_fifo_get_wait()`,
|
|
||||||
:cpp:func:`nano_fifo_get_wait()`
|
|
||||||
Remove an item from a FIFO, or waits for an item if it is empty.
|
|
||||||
|
|
||||||
:cpp:func:`nano_task_fifo_get_wait_timeout()`,
|
|
||||||
:cpp:func:`nano_fiber_fifo_get_wait_timeout()`,
|
|
||||||
:cpp:func:`nano_fifo_get_wait_timeout()`
|
|
||||||
Remove an item from a FIFO, or waits for an item for a specified time
|
Remove an item from a FIFO, or waits for an item for a specified time
|
||||||
period if it is empty.
|
period if it is empty.
|
|
@ -245,7 +245,7 @@ static void process_unack(void)
|
||||||
BT_DBG("Need to remove %u packet from the queue", number_removed);
|
BT_DBG("Need to remove %u packet from the queue", number_removed);
|
||||||
|
|
||||||
while (number_removed) {
|
while (number_removed) {
|
||||||
struct net_buf *buf = nano_fifo_get(&h5.unack_queue);
|
struct net_buf *buf = nano_fifo_get(&h5.unack_queue, TICKS_NONE);
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
BT_ERR("Unack queue is empty");
|
BT_ERR("Unack queue is empty");
|
||||||
|
@ -388,12 +388,12 @@ static void retx_fiber(int arg1, int arg2)
|
||||||
nano_fifo_init(&tmp_queue);
|
nano_fifo_init(&tmp_queue);
|
||||||
|
|
||||||
/* Queue to temperary queue */
|
/* Queue to temperary queue */
|
||||||
while ((buf = nano_fifo_get(&h5.tx_queue))) {
|
while ((buf = nano_fifo_get(&h5.tx_queue, TICKS_NONE))) {
|
||||||
nano_fifo_put(&tmp_queue, buf);
|
nano_fifo_put(&tmp_queue, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Queue unack packets to the beginning of the queue */
|
/* Queue unack packets to the beginning of the queue */
|
||||||
while ((buf = nano_fifo_get(&h5.unack_queue))) {
|
while ((buf = nano_fifo_get(&h5.unack_queue, TICKS_NONE))) {
|
||||||
/* include also packet type */
|
/* include also packet type */
|
||||||
net_buf_push(buf, sizeof(uint8_t));
|
net_buf_push(buf, sizeof(uint8_t));
|
||||||
nano_fifo_put(&h5.tx_queue, buf);
|
nano_fifo_put(&h5.tx_queue, buf);
|
||||||
|
@ -401,7 +401,7 @@ static void retx_fiber(int arg1, int arg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Queue saved packets from temp queue */
|
/* Queue saved packets from temp queue */
|
||||||
while ((buf = nano_fifo_get(&tmp_queue))) {
|
while ((buf = nano_fifo_get(&tmp_queue, TICKS_NONE))) {
|
||||||
nano_fifo_put(&h5.tx_queue, buf);
|
nano_fifo_put(&h5.tx_queue, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ static void tx_fiber(void)
|
||||||
fiber_sleep(10);
|
fiber_sleep(10);
|
||||||
break;
|
break;
|
||||||
case ACTIVE:
|
case ACTIVE:
|
||||||
buf = nano_fifo_get_wait(&h5.tx_queue);
|
buf = nano_fifo_get(&h5.tx_queue, TICKS_UNLIMITED);
|
||||||
type = h5_get_type(buf);
|
type = h5_get_type(buf);
|
||||||
|
|
||||||
h5_send(buf->data, type, buf->len);
|
h5_send(buf->data, type, buf->len);
|
||||||
|
@ -699,7 +699,7 @@ static void rx_fiber(void)
|
||||||
while (true) {
|
while (true) {
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
|
|
||||||
buf = nano_fifo_get_wait(&h5.rx_queue);
|
buf = nano_fifo_get(&h5.rx_queue, TICKS_UNLIMITED);
|
||||||
|
|
||||||
hexdump("=> ", buf->data, buf->len);
|
hexdump("=> ", buf->data, buf->len);
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ static void shell(int arg1, int arg2)
|
||||||
|
|
||||||
printk("%s", get_prompt());
|
printk("%s", get_prompt());
|
||||||
|
|
||||||
cmd = nano_fiber_fifo_get_wait(&cmds_queue);
|
cmd = nano_fiber_fifo_get(&cmds_queue, TICKS_UNLIMITED);
|
||||||
|
|
||||||
argc = line2argv(cmd->line, argv, ARRAY_SIZE(argv));
|
argc = line2argv(cmd->line, argv, ARRAY_SIZE(argv));
|
||||||
if (!argc) {
|
if (!argc) {
|
||||||
|
|
|
@ -308,7 +308,7 @@ void uart_console_isr(void *unused)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cmd) {
|
if (!cmd) {
|
||||||
cmd = nano_isr_fifo_get(avail_queue);
|
cmd = nano_isr_fifo_get(avail_queue, TICKS_NONE);
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,52 +384,27 @@ extern void nano_fifo_put(struct nano_fifo *fifo, void *data);
|
||||||
*
|
*
|
||||||
* @brief Get an element from the head a fifo
|
* @brief Get an element from the head a fifo
|
||||||
*
|
*
|
||||||
* Remove the head element from the specified nanokernel multiple-waiter fifo
|
* This is a convenience wrapper for the execution of context specific APIs.
|
||||||
* linked list fifo; it may be called from a fiber, task, or ISR context.
|
* It is helpful whenever the exact execution context is not known. Its use
|
||||||
|
* should be avoided whenever the context is known up-front (to avoid
|
||||||
|
* unnecessary overhead).
|
||||||
*
|
*
|
||||||
* If no elements are available, NULL is returned. The first word in the
|
* If no elements are available, NULL is returned. The first word in the
|
||||||
* element contains invalid data because that memory location was used to store
|
* element contains invalid data because that memory location was used to store
|
||||||
* a pointer to the next element in the linked list.
|
* a pointer to the next element in the linked list.
|
||||||
*
|
*
|
||||||
* @param fifo FIFO on which to interact.
|
* @param fifo FIFO on which to interact.
|
||||||
|
* @param timeout_in_ticks Affects the action taken should the fifo be empty.
|
||||||
|
* If TICKS_NONE, then return immediately. If TICKS_UNLIMITED, then wait as
|
||||||
|
* long as necessary. Otherwise wait up to the specified number of ticks
|
||||||
|
* before timing out.
|
||||||
|
*
|
||||||
|
* @warning If it is to be called from the context of an ISR, then @a
|
||||||
|
* timeout_in_ticks must be set to TICKS_NONE.
|
||||||
*
|
*
|
||||||
* @return Pointer to head element in the list if available, otherwise NULL
|
* @return Pointer to head element in the list if available, otherwise NULL
|
||||||
*/
|
*/
|
||||||
extern void *nano_fifo_get(struct nano_fifo *fifo);
|
extern void *nano_fifo_get(struct nano_fifo *fifo, int32_t timeout_in_ticks);
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @brief Get the head element of a fifo, poll/pend if empty
|
|
||||||
*
|
|
||||||
* This is a convenience wrapper for the execution context-specific APIs. This
|
|
||||||
* is helpful whenever the exact execution context is not known, but should be
|
|
||||||
* avoided when the context is known up-front (to avoid unnecessary overhead).
|
|
||||||
*
|
|
||||||
* @warning It's only valid to call this API from a fiber or a task.
|
|
||||||
*
|
|
||||||
* @param fifo FIFO on which to interact.
|
|
||||||
*
|
|
||||||
* @return Pointer to head element in the list
|
|
||||||
*/
|
|
||||||
extern void *nano_fifo_get_wait(struct nano_fifo *fifo);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @brief Get the head element of a fifo, poll/pend with timeout if empty
|
|
||||||
*
|
|
||||||
* This is a convenience wrapper for the execution context-specific APIs. This
|
|
||||||
* is helpful whenever the exact execution context is not known, but should be
|
|
||||||
* avoided when the context is known up-front (to avoid unnecessary overhead).
|
|
||||||
*
|
|
||||||
* @warning It's only valid to call this API from a fiber or a task.
|
|
||||||
*
|
|
||||||
* @param fifo FIFO on which to interact.
|
|
||||||
* @param timeout Timeout measured in ticks
|
|
||||||
*
|
|
||||||
* @return Pointer to head element in the list
|
|
||||||
*/
|
|
||||||
extern void *nano_fifo_get_wait_timeout(struct nano_fifo *fifo,
|
|
||||||
int32_t timeout);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* methods for ISRs
|
* methods for ISRs
|
||||||
|
@ -460,10 +435,11 @@ extern void nano_isr_fifo_put(struct nano_fifo *fifo, void *data);
|
||||||
* location was used to store a pointer to the next element in the linked list.
|
* location was used to store a pointer to the next element in the linked list.
|
||||||
*
|
*
|
||||||
* @param fifo FIFO on which to interact.
|
* @param fifo FIFO on which to interact.
|
||||||
|
* @param timeout_in_ticks Always use TICKS_NONE.
|
||||||
*
|
*
|
||||||
* @return Pointer to head element in the list if available, otherwise NULL
|
* @return Pointer to head element in the list if available, otherwise NULL
|
||||||
*/
|
*/
|
||||||
extern void *nano_isr_fifo_get(struct nano_fifo *fifo);
|
extern void *nano_isr_fifo_get(struct nano_fifo *fifo, int32_t timeout_in_ticks);
|
||||||
|
|
||||||
/* methods for fibers */
|
/* methods for fibers */
|
||||||
|
|
||||||
|
@ -492,58 +468,15 @@ extern void nano_fiber_fifo_put(struct nano_fifo *fifo, void *data);
|
||||||
* location was used to store a pointer to the next element in the linked list.
|
* location was used to store a pointer to the next element in the linked list.
|
||||||
*
|
*
|
||||||
* @param fifo FIFO on which to interact.
|
* @param fifo FIFO on which to interact.
|
||||||
|
* @param timeout_in_ticks Affects the action taken should the fifo be empty.
|
||||||
|
* If TICKS_NONE, then return immediately. If TICKS_UNLIMITED, then wait as
|
||||||
|
* long as necessary. Otherwise wait up to the specified number of ticks
|
||||||
|
* before timing out.
|
||||||
*
|
*
|
||||||
* @return Pointer to head element in the list if available, otherwise NULL
|
* @return Pointer to head element in the list if available, otherwise NULL
|
||||||
*/
|
*/
|
||||||
extern void *nano_fiber_fifo_get(struct nano_fifo *fifo);
|
extern void *nano_fiber_fifo_get(struct nano_fifo *fifo,
|
||||||
|
int32_t timeout_in_ticks);
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @brief Get the head element of a fifo, wait if empty
|
|
||||||
*
|
|
||||||
* Remove the head element from the specified system-level multiple-waiter
|
|
||||||
* fifo; it can only be called from a fiber.
|
|
||||||
*
|
|
||||||
* If no elements are available, the calling fiber will pend until an element
|
|
||||||
* is put onto the fifo.
|
|
||||||
*
|
|
||||||
* The first word in the element contains invalid data because that memory
|
|
||||||
* location was used to store a pointer to the next element in the linked list.
|
|
||||||
*
|
|
||||||
* @param fifo FIFO on which to interact.
|
|
||||||
*
|
|
||||||
* @return Pointer to head element in the list
|
|
||||||
*
|
|
||||||
* @note There exists a separate nano_task_fifo_get_wait() implementation
|
|
||||||
* since a task cannot pend on a nanokernel object. Instead tasks will
|
|
||||||
* poll the fifo object.
|
|
||||||
*/
|
|
||||||
extern void *nano_fiber_fifo_get_wait(struct nano_fifo *fifo);
|
|
||||||
#ifdef CONFIG_NANO_TIMEOUTS
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief get the head element of a fifo, pend with a timeout if empty
|
|
||||||
*
|
|
||||||
* Remove the head element from the specified nanokernel fifo; it can only be
|
|
||||||
* called from a fiber.
|
|
||||||
*
|
|
||||||
* If no elements are available, the calling fiber will pend until an element
|
|
||||||
* is put onto the fifo, or the timeout expires, whichever comes first.
|
|
||||||
*
|
|
||||||
* The first word in the element contains invalid data because that memory
|
|
||||||
* location was used to store a pointer to the next element in the linked
|
|
||||||
* list.
|
|
||||||
*
|
|
||||||
* @sa nano_task_stack_pop_wait()
|
|
||||||
*
|
|
||||||
* @param fifo the FIFO on which to interact.
|
|
||||||
* @param timeout_in_ticks time to wait in ticks
|
|
||||||
*
|
|
||||||
* @return Pointer to head element in the list, NULL if timed out
|
|
||||||
*/
|
|
||||||
extern void *nano_fiber_fifo_get_wait_timeout(struct nano_fifo *fifo,
|
|
||||||
int32_t timeout_in_ticks);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* methods for tasks */
|
/* methods for tasks */
|
||||||
|
|
||||||
|
@ -565,53 +498,25 @@ extern void *nano_fiber_fifo_get_wait_timeout(struct nano_fifo *fifo,
|
||||||
*/
|
*/
|
||||||
extern void nano_task_fifo_put(struct nano_fifo *fifo, void *data);
|
extern void nano_task_fifo_put(struct nano_fifo *fifo, void *data);
|
||||||
|
|
||||||
extern void *nano_task_fifo_get(struct nano_fifo *fifo);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @brief Get an element from the head of a FIFO from a task, poll if empty
|
||||||
*
|
*
|
||||||
* @brief Get the head element of a fifo, poll if empty
|
* Remove the head element from the specified nanokernel multiple-waiter fifo
|
||||||
*
|
* linked list fifo. It may be called from a task.
|
||||||
* Remove the head element from the specified system-level multiple-waiter
|
|
||||||
* fifo; it can only be called from a task.
|
|
||||||
*
|
|
||||||
* If no elements are available, the calling task will poll until an
|
|
||||||
* until an element is put onto the fifo.
|
|
||||||
*
|
*
|
||||||
* The first word in the element contains invalid data because that memory
|
* The first word in the element contains invalid data because that memory
|
||||||
* location was used to store a pointer to the next element in the linked list.
|
* location was used to store a pointer to the next element in the linked list.
|
||||||
*
|
*
|
||||||
* @param fifo FIFO on which to interact.
|
* @param fifo FIFO on which to interact.
|
||||||
|
* @param timeout_in_ticks Affects the action taken should the fifo be empty.
|
||||||
|
* If TICKS_NONE, then return immediately. If TICKS_UNLIMITED, then poll as
|
||||||
|
* long as necessary. Otherwise poll up to the specified number of ticks have
|
||||||
|
* elapsed before timing out.
|
||||||
*
|
*
|
||||||
* @sa nano_task_stack_pop_wait()
|
* @return Pointer to head element in the list if available, otherwise NULL
|
||||||
*
|
|
||||||
* @return Pointer to head element in the list
|
|
||||||
*/
|
*/
|
||||||
extern void *nano_task_fifo_get_wait(struct nano_fifo *fifo);
|
extern void *nano_task_fifo_get(struct nano_fifo *fifo,
|
||||||
#ifdef CONFIG_NANO_TIMEOUTS
|
int32_t timeout_in_ticks);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief get the head element of a fifo, poll with a timeout if empty
|
|
||||||
*
|
|
||||||
* Remove the head element from the specified nanokernel fifo; it can only be
|
|
||||||
* called from a task.
|
|
||||||
*
|
|
||||||
* If no elements are available, the calling task will poll until an element
|
|
||||||
* is put onto the fifo, or the timeout expires, whichever comes first.
|
|
||||||
*
|
|
||||||
* The first word in the element contains invalid data because that memory
|
|
||||||
* location was used to store a pointer to the next element in the linked
|
|
||||||
* list.
|
|
||||||
*
|
|
||||||
* @sa nano_task_stack_pop_wait()
|
|
||||||
*
|
|
||||||
* @param fifo the FIFO on which to operate
|
|
||||||
* @param timeout_in_ticks time to wait in ticks
|
|
||||||
*
|
|
||||||
* @return Pointer to head element in the list, NULL if timed out
|
|
||||||
*/
|
|
||||||
extern void *nano_task_fifo_get_wait_timeout(struct nano_fifo *fifo,
|
|
||||||
int32_t timeout_in_ticks);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* LIFO APIs */
|
/* LIFO APIs */
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
* nano_fifo_init
|
* nano_fifo_init
|
||||||
* nano_fiber_fifo_put, nano_task_fifo_put, nano_isr_fifo_put
|
* nano_fiber_fifo_put, nano_task_fifo_put, nano_isr_fifo_put
|
||||||
* nano_fiber_fifo_get, nano_task_fifo_get, nano_isr_fifo_get
|
* nano_fiber_fifo_get, nano_task_fifo_get, nano_isr_fifo_get
|
||||||
* nano_fiber_fifo_get_wait, nano_task_fifo_get_wait
|
* nano_fifo_get
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -158,11 +158,6 @@ void nano_fifo_put(struct nano_fifo *fifo, void *data)
|
||||||
func[sys_execution_context_type_get()](fifo, data);
|
func[sys_execution_context_type_get()](fifo, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUNC_ALIAS(_fifo_get, nano_isr_fifo_get, void *);
|
|
||||||
FUNC_ALIAS(_fifo_get, nano_fiber_fifo_get, void *);
|
|
||||||
FUNC_ALIAS(_fifo_get, nano_task_fifo_get, void *);
|
|
||||||
FUNC_ALIAS(_fifo_get, nano_fifo_get, void *);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Internal routine to remove data from a fifo
|
* @brief Internal routine to remove data from a fifo
|
||||||
|
@ -187,174 +182,79 @@ static inline void *dequeue_data(struct nano_fifo *fifo)
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
FUNC_ALIAS(_fifo_get, nano_isr_fifo_get, void *);
|
||||||
* INTERNAL
|
FUNC_ALIAS(_fifo_get, nano_fiber_fifo_get, void *);
|
||||||
* This function is capable of supporting invocations from fiber, task, and ISR
|
|
||||||
* execution contexts. However, the nano_isr_fifo_get, nano_task_fifo_get, and
|
void *_fifo_get(struct nano_fifo *fifo, int32_t timeout_in_ticks)
|
||||||
* nano_fiber_fifo_get aliases are created to support any required
|
|
||||||
* implementation differences in the future without introducing a source code
|
|
||||||
* migration issue.
|
|
||||||
*/
|
|
||||||
void *_fifo_get(struct nano_fifo *fifo)
|
|
||||||
{
|
{
|
||||||
|
unsigned int key;
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
unsigned int imask;
|
|
||||||
|
|
||||||
imask = irq_lock();
|
key = irq_lock();
|
||||||
|
|
||||||
if (fifo->stat > 0) {
|
if (likely(fifo->stat > 0)) {
|
||||||
fifo->stat--;
|
fifo->stat--;
|
||||||
data = dequeue_data(fifo);
|
data = dequeue_data(fifo);
|
||||||
}
|
} else if (timeout_in_ticks != TICKS_NONE) {
|
||||||
irq_unlock(imask);
|
fifo->stat--;
|
||||||
return data;
|
_NANO_TIMEOUT_ADD(&fifo->wait_q, timeout_in_ticks);
|
||||||
}
|
|
||||||
|
|
||||||
void *nano_fiber_fifo_get_wait(struct nano_fifo *fifo)
|
|
||||||
{
|
|
||||||
void *data;
|
|
||||||
unsigned int imask;
|
|
||||||
|
|
||||||
imask = irq_lock();
|
|
||||||
|
|
||||||
fifo->stat--;
|
|
||||||
if (fifo->stat < 0) {
|
|
||||||
_nano_wait_q_put(&fifo->wait_q);
|
|
||||||
data = (void *)_Swap(imask);
|
|
||||||
} else {
|
|
||||||
data = dequeue_data(fifo);
|
|
||||||
irq_unlock(imask);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *nano_task_fifo_get_wait(struct nano_fifo *fifo)
|
|
||||||
{
|
|
||||||
void *data;
|
|
||||||
unsigned int imask;
|
|
||||||
|
|
||||||
/* spin until data is put onto the FIFO */
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
imask = irq_lock();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Predict that the branch will be taken to break out of the loop.
|
|
||||||
* There is little cost to a misprediction since that leads to idle.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (likely(fifo->stat > 0))
|
|
||||||
break;
|
|
||||||
|
|
||||||
/* see explanation in nano_stack.c:nano_task_stack_pop_wait() */
|
|
||||||
|
|
||||||
nano_cpu_atomic_idle(imask);
|
|
||||||
}
|
|
||||||
|
|
||||||
fifo->stat--;
|
|
||||||
data = dequeue_data(fifo);
|
|
||||||
irq_unlock(imask);
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *nano_fifo_get_wait(struct nano_fifo *fifo)
|
|
||||||
{
|
|
||||||
static void *(*func[3])(struct nano_fifo *fifo) = {
|
|
||||||
NULL,
|
|
||||||
nano_fiber_fifo_get_wait,
|
|
||||||
nano_task_fifo_get_wait
|
|
||||||
};
|
|
||||||
|
|
||||||
return func[sys_execution_context_type_get()](fifo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_NANO_TIMEOUTS
|
|
||||||
|
|
||||||
void *nano_fiber_fifo_get_wait_timeout(struct nano_fifo *fifo,
|
|
||||||
int32_t timeout_in_ticks)
|
|
||||||
{
|
|
||||||
unsigned int key;
|
|
||||||
void *data;
|
|
||||||
|
|
||||||
if (unlikely(TICKS_UNLIMITED == timeout_in_ticks)) {
|
|
||||||
return nano_fiber_fifo_get_wait(fifo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(TICKS_NONE == timeout_in_ticks)) {
|
|
||||||
return nano_fiber_fifo_get(fifo);
|
|
||||||
}
|
|
||||||
|
|
||||||
key = irq_lock();
|
|
||||||
|
|
||||||
fifo->stat--;
|
|
||||||
if (fifo->stat < 0) {
|
|
||||||
_nano_timeout_add(_nanokernel.current, &fifo->wait_q, timeout_in_ticks);
|
|
||||||
_nano_wait_q_put(&fifo->wait_q);
|
_nano_wait_q_put(&fifo->wait_q);
|
||||||
data = (void *)_Swap(key);
|
data = (void *)_Swap(key);
|
||||||
} else {
|
return data;
|
||||||
data = dequeue_data(fifo);
|
|
||||||
irq_unlock(key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
irq_unlock(key);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *nano_task_fifo_get_wait_timeout(struct nano_fifo *fifo,
|
void *nano_task_fifo_get(struct nano_fifo *fifo, int32_t timeout_in_ticks)
|
||||||
int32_t timeout_in_ticks)
|
|
||||||
{
|
{
|
||||||
int64_t cur_ticks, limit;
|
int64_t cur_ticks;
|
||||||
|
int64_t limit = 0x7fffffffffffffffll;
|
||||||
unsigned int key;
|
unsigned int key;
|
||||||
void *data;
|
|
||||||
|
|
||||||
if (unlikely(TICKS_UNLIMITED == timeout_in_ticks)) {
|
|
||||||
return nano_task_fifo_get_wait(fifo);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(TICKS_NONE == timeout_in_ticks)) {
|
|
||||||
return nano_task_fifo_get(fifo);
|
|
||||||
}
|
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
cur_ticks = sys_tick_get();
|
cur_ticks = _NANO_TIMEOUT_TICK_GET();
|
||||||
limit = cur_ticks + timeout_in_ticks;
|
if (timeout_in_ticks != TICKS_UNLIMITED) {
|
||||||
|
limit = cur_ticks + timeout_in_ticks;
|
||||||
while (cur_ticks < limit) {
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
/*
|
/*
|
||||||
* Predict that the branch will be taken to break out of the loop.
|
* Predict that the branch will be taken to break out of the loop.
|
||||||
* There is little cost to a misprediction since that leads to idle.
|
* There is little cost to a misprediction since that leads to idle.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (likely(fifo->stat > 0)) {
|
if (likely(fifo->stat > 0)) {
|
||||||
|
void *data;
|
||||||
|
|
||||||
fifo->stat--;
|
fifo->stat--;
|
||||||
data = dequeue_data(fifo);
|
data = dequeue_data(fifo);
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* see explanation in nano_stack.c:nano_task_stack_pop_wait() */
|
if (timeout_in_ticks != TICKS_NONE) {
|
||||||
|
/* see explanation in nano_stack.c:nano_task_stack_pop_wait() */
|
||||||
|
|
||||||
nano_cpu_atomic_idle(key);
|
nano_cpu_atomic_idle(key);
|
||||||
|
|
||||||
key = irq_lock();
|
key = irq_lock();
|
||||||
cur_ticks = sys_tick_get();
|
cur_ticks = _NANO_TIMEOUT_TICK_GET();
|
||||||
}
|
}
|
||||||
|
} while (cur_ticks < limit);
|
||||||
|
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *nano_fifo_get_wait_timeout(struct nano_fifo *fifo, int32_t timeout)
|
void *nano_fifo_get(struct nano_fifo *fifo, int32_t timeout)
|
||||||
{
|
{
|
||||||
static void *(*func[3])(struct nano_fifo *, int32_t) = {
|
static void *(*func[3])(struct nano_fifo *, int32_t) = {
|
||||||
NULL,
|
nano_isr_fifo_get,
|
||||||
nano_fiber_fifo_get_wait_timeout,
|
nano_fiber_fifo_get,
|
||||||
nano_task_fifo_get_wait_timeout
|
nano_task_fifo_get
|
||||||
};
|
};
|
||||||
|
|
||||||
return func[sys_execution_context_type_get()](fifo, timeout);
|
return func[sys_execution_context_type_get()](fifo, timeout);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NANO_TIMEOUTS */
|
|
||||||
|
|
|
@ -473,7 +473,7 @@ static void conn_tx_fiber(int arg1, int arg2)
|
||||||
|
|
||||||
while (conn->state == BT_CONN_CONNECTED) {
|
while (conn->state == BT_CONN_CONNECTED) {
|
||||||
/* Get next ACL packet for connection */
|
/* Get next ACL packet for connection */
|
||||||
buf = nano_fifo_get_wait(&conn->tx_queue);
|
buf = nano_fifo_get(&conn->tx_queue, TICKS_UNLIMITED);
|
||||||
if (conn->state != BT_CONN_CONNECTED) {
|
if (conn->state != BT_CONN_CONNECTED) {
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
break;
|
break;
|
||||||
|
@ -487,7 +487,7 @@ static void conn_tx_fiber(int arg1, int arg2)
|
||||||
BT_DBG("handle %u disconnected - cleaning up", conn->handle);
|
BT_DBG("handle %u disconnected - cleaning up", conn->handle);
|
||||||
|
|
||||||
/* Give back any allocated buffers */
|
/* Give back any allocated buffers */
|
||||||
while ((buf = nano_fifo_get(&conn->tx_queue))) {
|
while ((buf = nano_fifo_get(&conn->tx_queue, TICKS_NONE))) {
|
||||||
net_buf_unref(buf);
|
net_buf_unref(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1729,7 +1729,7 @@ static void hci_cmd_tx_fiber(void)
|
||||||
|
|
||||||
/* Get next command - wait if necessary */
|
/* Get next command - wait if necessary */
|
||||||
BT_DBG("calling fifo_get_wait");
|
BT_DBG("calling fifo_get_wait");
|
||||||
buf = nano_fifo_get_wait(&bt_dev.cmd_tx_queue);
|
buf = nano_fifo_get(&bt_dev.cmd_tx_queue, TICKS_UNLIMITED);
|
||||||
bt_dev.ncmd = 0;
|
bt_dev.ncmd = 0;
|
||||||
|
|
||||||
/* Clear out any existing sent command */
|
/* Clear out any existing sent command */
|
||||||
|
@ -1765,7 +1765,7 @@ static void rx_prio_fiber(void)
|
||||||
struct bt_hci_evt_hdr *hdr;
|
struct bt_hci_evt_hdr *hdr;
|
||||||
|
|
||||||
BT_DBG("calling fifo_get_wait");
|
BT_DBG("calling fifo_get_wait");
|
||||||
buf = nano_fifo_get_wait(&bt_dev.rx_prio_queue);
|
buf = nano_fifo_get(&bt_dev.rx_prio_queue, TICKS_UNLIMITED);
|
||||||
|
|
||||||
BT_DBG("buf %p type %u len %u", buf, bt_type(buf), buf->len);
|
BT_DBG("buf %p type %u len %u", buf, bt_type(buf), buf->len);
|
||||||
|
|
||||||
|
@ -2281,7 +2281,7 @@ static void hci_rx_fiber(bt_ready_cb_t ready_cb)
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
BT_DBG("calling fifo_get_wait");
|
BT_DBG("calling fifo_get_wait");
|
||||||
buf = nano_fifo_get_wait(&bt_dev.rx_queue);
|
buf = nano_fifo_get(&bt_dev.rx_queue, TICKS_UNLIMITED);
|
||||||
|
|
||||||
BT_DBG("buf %p type %u len %u", buf, bt_type(buf), buf->len);
|
BT_DBG("buf %p type %u len %u", buf, bt_type(buf), buf->len);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct net_buf *net_buf_get(struct nano_fifo *fifo, size_t reserve_head)
|
||||||
|
|
||||||
NET_BUF_DBG("fifo %p reserve %u\n", fifo, reserve_head);
|
NET_BUF_DBG("fifo %p reserve %u\n", fifo, reserve_head);
|
||||||
|
|
||||||
buf = nano_fifo_get(fifo);
|
buf = nano_fifo_get(fifo, TICKS_NONE);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
if (sys_execution_context_type_get() == NANO_CTX_ISR) {
|
if (sys_execution_context_type_get() == NANO_CTX_ISR) {
|
||||||
NET_BUF_ERR("Failed to get free buffer\n");
|
NET_BUF_ERR("Failed to get free buffer\n");
|
||||||
|
@ -57,7 +57,7 @@ struct net_buf *net_buf_get(struct nano_fifo *fifo, size_t reserve_head)
|
||||||
}
|
}
|
||||||
|
|
||||||
NET_BUF_WARN("Low on buffers. Waiting (fifo %p)\n", fifo);
|
NET_BUF_WARN("Low on buffers. Waiting (fifo %p)\n", fifo);
|
||||||
buf = nano_fifo_get_wait(fifo);
|
buf = nano_fifo_get(fifo, TICKS_UNLIMITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->ref = 1;
|
buf->ref = 1;
|
||||||
|
|
|
@ -381,9 +381,9 @@ static inline struct net_buf *buf_wait_timeout(struct nano_fifo *queue,
|
||||||
{
|
{
|
||||||
switch (sys_execution_context_type_get()) {
|
switch (sys_execution_context_type_get()) {
|
||||||
case NANO_CTX_FIBER:
|
case NANO_CTX_FIBER:
|
||||||
return nano_fiber_fifo_get_wait_timeout(queue, timeout);
|
return nano_fiber_fifo_get(queue, timeout);
|
||||||
case NANO_CTX_TASK:
|
case NANO_CTX_TASK:
|
||||||
return nano_task_fifo_get_wait_timeout(queue, timeout);
|
return nano_task_fifo_get(queue, timeout);
|
||||||
case NANO_CTX_ISR:
|
case NANO_CTX_ISR:
|
||||||
default:
|
default:
|
||||||
/* Invalid context type */
|
/* Invalid context type */
|
||||||
|
@ -454,16 +454,16 @@ struct net_buf *net_receive(struct net_context *context, int32_t timeout)
|
||||||
|
|
||||||
switch (timeout) {
|
switch (timeout) {
|
||||||
case TICKS_UNLIMITED:
|
case TICKS_UNLIMITED:
|
||||||
buf = nano_fifo_get_wait(rx_queue);
|
buf = nano_fifo_get(rx_queue, TICKS_UNLIMITED);
|
||||||
break;
|
break;
|
||||||
case TICKS_NONE:
|
case TICKS_NONE:
|
||||||
buf = nano_fifo_get(rx_queue);
|
buf = nano_fifo_get(rx_queue, TICKS_NONE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
#ifdef CONFIG_NANO_TIMEOUTS
|
#ifdef CONFIG_NANO_TIMEOUTS
|
||||||
buf = buf_wait_timeout(rx_queue, timeout);
|
buf = buf_wait_timeout(rx_queue, timeout);
|
||||||
#else /* CONFIG_NANO_TIMEOUTS */
|
#else /* CONFIG_NANO_TIMEOUTS */
|
||||||
buf = nano_fifo_get(rx_queue);
|
buf = nano_fifo_get(rx_queue, TICKS_NONE);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -581,7 +581,7 @@ static void net_tx_fiber(void)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Get next packet from application - wait if necessary */
|
/* Get next packet from application - wait if necessary */
|
||||||
buf = nano_fifo_get_wait(&netdev.tx_queue);
|
buf = nano_fifo_get(&netdev.tx_queue, TICKS_UNLIMITED);
|
||||||
|
|
||||||
NET_DBG("Sending (buf %p, len %u) to IP stack\n",
|
NET_DBG("Sending (buf %p, len %u) to IP stack\n",
|
||||||
buf, buf->len);
|
buf, buf->len);
|
||||||
|
@ -624,7 +624,7 @@ static void net_rx_fiber(void)
|
||||||
NET_DBG("Starting RX fiber\n");
|
NET_DBG("Starting RX fiber\n");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
buf = nano_fifo_get_wait(&netdev.rx_queue);
|
buf = nano_fifo_get(&netdev.rx_queue, TICKS_UNLIMITED);
|
||||||
|
|
||||||
/* Check stack usage (no-op if not enabled) */
|
/* Check stack usage (no-op if not enabled) */
|
||||||
net_analyze_stack("RX fiber", rx_fiber_stack,
|
net_analyze_stack("RX fiber", rx_fiber_stack,
|
||||||
|
|
|
@ -87,7 +87,7 @@ static void net_tx_15_4_fiber(void)
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
|
|
||||||
/* Get next packet from application - wait if necessary */
|
/* Get next packet from application - wait if necessary */
|
||||||
buf = nano_fifo_get_wait(&tx_queue);
|
buf = nano_fifo_get(&tx_queue, TICKS_UNLIMITED);
|
||||||
|
|
||||||
if (uip_len(buf) == 0) {
|
if (uip_len(buf) == 0) {
|
||||||
/* It is possible that uIP stack overwrote the len.
|
/* It is possible that uIP stack overwrote the len.
|
||||||
|
@ -120,7 +120,7 @@ static void net_rx_15_4_fiber(void)
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
/* Wait next packet from 15.4 stack */
|
/* Wait next packet from 15.4 stack */
|
||||||
buf = nano_fifo_get_wait(&rx_queue);
|
buf = nano_fifo_get(&rx_queue, TICKS_UNLIMITED);
|
||||||
|
|
||||||
#if NET_MAC_CONF_STATS
|
#if NET_MAC_CONF_STATS
|
||||||
byte_count = uip_pkt_buflen(buf);
|
byte_count = uip_pkt_buflen(buf);
|
||||||
|
|
|
@ -128,7 +128,7 @@ static void cmd_handler(int arg1, int arg2)
|
||||||
struct btp_hdr *cmd;
|
struct btp_hdr *cmd;
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
|
|
||||||
cmd = nano_fiber_fifo_get_wait(&cmds_queue);
|
cmd = nano_fiber_fifo_get(&cmds_queue, TICKS_UNLIMITED);
|
||||||
|
|
||||||
len = sys_le16_to_cpu(cmd->len);
|
len = sys_le16_to_cpu(cmd->len);
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ static uint8_t *recv_cb(uint8_t *buf, size_t *off)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_buf = nano_fifo_get(&avail_queue);
|
new_buf = nano_fifo_get(&avail_queue, TICKS_NONE);
|
||||||
if (!new_buf) {
|
if (!new_buf) {
|
||||||
printk("BT tester: RX overflow\n");
|
printk("BT tester: RX overflow\n");
|
||||||
*off = 0;
|
*off = 0;
|
||||||
|
@ -205,7 +205,8 @@ void tester_init(void)
|
||||||
|
|
||||||
task_fiber_start(stack, STACKSIZE, cmd_handler, 0, 0, 7, 0);
|
task_fiber_start(stack, STACKSIZE, cmd_handler, 0, 0, 7, 0);
|
||||||
|
|
||||||
uart_pipe_register(nano_fifo_get(&avail_queue), BTP_MTU, recv_cb);
|
uart_pipe_register(nano_fifo_get(&avail_queue, TICKS_NONE),
|
||||||
|
BTP_MTU, recv_cb);
|
||||||
|
|
||||||
printk("BT tester initialized\n");
|
printk("BT tester initialized\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ END TEST CASE
|
||||||
TEST CASE: FIFO #1
|
TEST CASE: FIFO #1
|
||||||
TEST COVERAGE:
|
TEST COVERAGE:
|
||||||
nano_fifo_init
|
nano_fifo_init
|
||||||
nano_fiber_fifo_get_wait
|
nano_fiber_fifo_get
|
||||||
nano_fiber_fifo_put
|
nano_fiber_fifo_put
|
||||||
Starting test. Please wait...
|
Starting test. Please wait...
|
||||||
TEST RESULT: SUCCESSFUL
|
TEST RESULT: SUCCESSFUL
|
||||||
|
@ -117,7 +117,7 @@ END TEST CASE
|
||||||
TEST CASE: FIFO #2
|
TEST CASE: FIFO #2
|
||||||
TEST COVERAGE:
|
TEST COVERAGE:
|
||||||
nano_fifo_init
|
nano_fifo_init
|
||||||
nano_fiber_fifo_get_wait
|
nano_fiber_fifo_get(TICKS_UNLIMITED)
|
||||||
nano_fiber_fifo_get
|
nano_fiber_fifo_get
|
||||||
nano_fiber_fifo_put
|
nano_fiber_fifo_put
|
||||||
fiber_yield
|
fiber_yield
|
||||||
|
@ -129,9 +129,9 @@ END TEST CASE
|
||||||
TEST CASE: FIFO #3
|
TEST CASE: FIFO #3
|
||||||
TEST COVERAGE:
|
TEST COVERAGE:
|
||||||
nano_fifo_init
|
nano_fifo_init
|
||||||
nano_fiber_fifo_get_wait
|
nano_fiber_fifo_get
|
||||||
nano_fiber_fifo_put
|
nano_fiber_fifo_put
|
||||||
nano_task_fifo_get_wait
|
nano_task_fifo_get
|
||||||
nano_task_fifo_put
|
nano_task_fifo_put
|
||||||
Starting test. Please wait...
|
Starting test. Please wait...
|
||||||
TEST RESULT: SUCCESSFUL
|
TEST RESULT: SUCCESSFUL
|
||||||
|
|
|
@ -40,9 +40,9 @@ Starting timer tests
|
||||||
===================================================================
|
===================================================================
|
||||||
Test the allocation of timers.
|
Test the allocation of timers.
|
||||||
Test the one shot feature of a timer.
|
Test the one shot feature of a timer.
|
||||||
test nano_task_fifo_get_wait_timeout with timeout > 0
|
test nano_task_fifo_get with timeout > 0
|
||||||
nano_task_fifo_get_wait_timeout timed out as expected
|
nano_task_fifo_get timed out as expected
|
||||||
nano_task_fifo_get_wait_timeout got fifo in time, as expected
|
nano_task_fifo_get got fifo in time, as expected
|
||||||
testing timeouts of 5 fibers on same fifo
|
testing timeouts of 5 fibers on same fifo
|
||||||
got fiber (q order: 2, t/o: 10, fifo 00109134) as expected
|
got fiber (q order: 2, t/o: 10, fifo 00109134) as expected
|
||||||
got fiber (q order: 3, t/o: 15, fifo 00109134) as expected
|
got fiber (q order: 3, t/o: 15, fifo 00109134) as expected
|
||||||
|
|
|
@ -107,7 +107,7 @@ END TEST CASE
|
||||||
TEST CASE: FIFO #1
|
TEST CASE: FIFO #1
|
||||||
TEST COVERAGE:
|
TEST COVERAGE:
|
||||||
nano_fifo_init
|
nano_fifo_init
|
||||||
nano_fiber_fifo_get_wait
|
nano_fiber_fifo_get(TICKS_UNLIMITED)
|
||||||
nano_fiber_fifo_put
|
nano_fiber_fifo_put
|
||||||
Starting test. Please wait...
|
Starting test. Please wait...
|
||||||
TEST RESULT: SUCCESSFUL
|
TEST RESULT: SUCCESSFUL
|
||||||
|
@ -117,7 +117,7 @@ END TEST CASE
|
||||||
TEST CASE: FIFO #2
|
TEST CASE: FIFO #2
|
||||||
TEST COVERAGE:
|
TEST COVERAGE:
|
||||||
nano_fifo_init
|
nano_fifo_init
|
||||||
nano_fiber_fifo_get_wait
|
nano_fiber_fifo_get(TICKS_UNLIMITED)
|
||||||
nano_fiber_fifo_get
|
nano_fiber_fifo_get
|
||||||
nano_fiber_fifo_put
|
nano_fiber_fifo_put
|
||||||
fiber_yield
|
fiber_yield
|
||||||
|
@ -129,7 +129,7 @@ END TEST CASE
|
||||||
TEST CASE: FIFO #3
|
TEST CASE: FIFO #3
|
||||||
TEST COVERAGE:
|
TEST COVERAGE:
|
||||||
nano_fifo_init
|
nano_fifo_init
|
||||||
nano_fiber_fifo_get_wait
|
nano_fiber_fifo_get(TICKS_UNLIMITED)
|
||||||
nano_fiber_fifo_put
|
nano_fiber_fifo_put
|
||||||
nano_task_fifo_get_wait
|
nano_task_fifo_get_wait
|
||||||
nano_task_fifo_put
|
nano_task_fifo_put
|
||||||
|
|
|
@ -69,7 +69,7 @@ void lifo_fiber1(int par1, int par2)
|
||||||
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(&nanoFifo_sync, TICKS_UNLIMITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ void lifo_fiber2(int par1, int par2)
|
||||||
(*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(&nanoFifo_sync, TICKS_UNLIMITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +130,7 @@ void lifo_fiber3(int par1, int par2)
|
||||||
(*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(&nanoFifo_sync, TICKS_UNLIMITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -54,7 +54,7 @@ void fifo_fiber1(int par1, int par2)
|
||||||
|
|
||||||
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(&nanoFifo1, TICKS_UNLIMITED);
|
||||||
if (pelement[1] != i) {
|
if (pelement[1] != i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ void fifo_fiber1(int par1, int par2)
|
||||||
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(&nanoFifo_sync, TICKS_UNLIMITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,14 +85,14 @@ void fifo_fiber2(int par1, int par2)
|
||||||
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(&nanoFifo2, TICKS_UNLIMITED);
|
||||||
if (pelement[1] != i) {
|
if (pelement[1] != i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
(*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(&nanoFifo_sync, TICKS_UNLIMITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,7 +115,8 @@ void fifo_fiber3(int par1, int par2)
|
||||||
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 ((pelement = nano_fiber_fifo_get(&nanoFifo2,
|
||||||
|
TICKS_NONE)) == NULL) {
|
||||||
fiber_yield();
|
fiber_yield();
|
||||||
}
|
}
|
||||||
if (pelement[1] != i) {
|
if (pelement[1] != i) {
|
||||||
|
@ -124,7 +125,7 @@ void fifo_fiber3(int par1, int par2)
|
||||||
(*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(&nanoFifo_sync, TICKS_UNLIMITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,7 +150,7 @@ int fifo_test(void)
|
||||||
"FIFO #1");
|
"FIFO #1");
|
||||||
fprintf(output_file, sz_description,
|
fprintf(output_file, sz_description,
|
||||||
"\n\tnano_fifo_init"
|
"\n\tnano_fifo_init"
|
||||||
"\n\tnano_fiber_fifo_get_wait"
|
"\n\tnano_fiber_fifo_get(TICKS_UNLIMITED)"
|
||||||
"\n\tnano_fiber_fifo_put");
|
"\n\tnano_fiber_fifo_put");
|
||||||
printf(sz_test_start_fmt);
|
printf(sz_test_start_fmt);
|
||||||
|
|
||||||
|
@ -176,8 +177,8 @@ int fifo_test(void)
|
||||||
"FIFO #2");
|
"FIFO #2");
|
||||||
fprintf(output_file, sz_description,
|
fprintf(output_file, sz_description,
|
||||||
"\n\tnano_fifo_init"
|
"\n\tnano_fifo_init"
|
||||||
"\n\tnano_fiber_fifo_get_wait"
|
"\n\tnano_fiber_fifo_get(TICKS_UNLIMITED)"
|
||||||
"\n\tnano_fiber_fifo_get"
|
"\n\tnano_fiber_fifo_get(TICKS_NONE)"
|
||||||
"\n\tnano_fiber_fifo_put"
|
"\n\tnano_fiber_fifo_put"
|
||||||
"\n\tfiber_yield");
|
"\n\tfiber_yield");
|
||||||
printf(sz_test_start_fmt);
|
printf(sz_test_start_fmt);
|
||||||
|
@ -206,9 +207,9 @@ int fifo_test(void)
|
||||||
"FIFO #3");
|
"FIFO #3");
|
||||||
fprintf(output_file, sz_description,
|
fprintf(output_file, sz_description,
|
||||||
"\n\tnano_fifo_init"
|
"\n\tnano_fifo_init"
|
||||||
"\n\tnano_fiber_fifo_get_wait"
|
"\n\tnano_fiber_fifo_get(TICKS_UNLIMITED)"
|
||||||
"\n\tnano_fiber_fifo_put"
|
"\n\tnano_fiber_fifo_put"
|
||||||
"\n\tnano_task_fifo_get_wait"
|
"\n\tnano_task_fifo_get(TICKS_UNLIMITED)"
|
||||||
"\n\tnano_task_fifo_put");
|
"\n\tnano_task_fifo_put");
|
||||||
printf(sz_test_start_fmt);
|
printf(sz_test_start_fmt);
|
||||||
|
|
||||||
|
@ -228,11 +229,11 @@ int fifo_test(void)
|
||||||
element[1] = i;
|
element[1] = i;
|
||||||
nano_task_fifo_put(&nanoFifo1, element);
|
nano_task_fifo_put(&nanoFifo1, element);
|
||||||
|
|
||||||
pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2);
|
pelement = (int *) nano_task_fifo_get(&nanoFifo2, TICKS_UNLIMITED);
|
||||||
if (pelement[1] != i) {
|
if (pelement[1] != i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pelement = (int *) nano_task_fifo_get_wait(&nanoFifo2);
|
pelement = (int *) nano_task_fifo_get(&nanoFifo2, TICKS_UNLIMITED);
|
||||||
if (pelement[1] != i) {
|
if (pelement[1] != i) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -725,8 +725,7 @@ static int test_timeout(void)
|
||||||
}
|
}
|
||||||
for (ii = 0; ii < NUM_TIMEOUT_FIBERS; ii++) {
|
for (ii = 0; ii < NUM_TIMEOUT_FIBERS; ii++) {
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait_timeout(&timeout_order_fifo,
|
data = nano_task_fifo_get(&timeout_order_fifo, TIMEOUT_TWO_INTERVALS);
|
||||||
TIMEOUT_TWO_INTERVALS);
|
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
TC_ERROR(" *** timeout while waiting for delayed fiber\n");
|
TC_ERROR(" *** timeout while waiting for delayed fiber\n");
|
||||||
|
@ -745,8 +744,7 @@ static int test_timeout(void)
|
||||||
|
|
||||||
/* ensure no more fibers fire */
|
/* ensure no more fibers fire */
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait_timeout(&timeout_order_fifo,
|
data = nano_task_fifo_get(&timeout_order_fifo, TIMEOUT_TWO_INTERVALS);
|
||||||
TIMEOUT_TWO_INTERVALS);
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
TC_ERROR(" *** got something on the fifo, but shouldn't have...\n");
|
TC_ERROR(" *** got something on the fifo, but shouldn't have...\n");
|
||||||
|
@ -787,8 +785,7 @@ static int test_timeout(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait_timeout(&timeout_order_fifo,
|
data = nano_task_fifo_get(&timeout_order_fifo, TIMEOUT_TEN_INTERVALS);
|
||||||
TIMEOUT_TEN_INTERVALS);
|
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
TC_ERROR(" *** timeout while waiting for delayed fiber\n");
|
TC_ERROR(" *** timeout while waiting for delayed fiber\n");
|
||||||
|
@ -813,8 +810,7 @@ static int test_timeout(void)
|
||||||
|
|
||||||
/* ensure no more fibers fire */
|
/* ensure no more fibers fire */
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait_timeout(&timeout_order_fifo,
|
data = nano_task_fifo_get(&timeout_order_fifo, TIMEOUT_TWO_INTERVALS);
|
||||||
TIMEOUT_TWO_INTERVALS);
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
TC_ERROR(" *** got something on the fifo, but shouldn't have...\n");
|
TC_ERROR(" *** got something on the fifo, but shouldn't have...\n");
|
||||||
|
|
|
@ -74,7 +74,7 @@ void main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ii = 0; ii < N_FIBERS; ii++) {
|
for (int ii = 0; ii < N_FIBERS; ii++) {
|
||||||
struct result *p = nano_task_fifo_get_wait_timeout(&fifo, 10);
|
struct result *p = nano_task_fifo_get(&fifo, 10);
|
||||||
|
|
||||||
if (!p || !p->pass) {
|
if (!p || !p->pass) {
|
||||||
rv = TC_FAIL;
|
rv = TC_FAIL;
|
||||||
|
|
|
@ -86,9 +86,9 @@ Get from queue1: count = 3, ptr is 00103e80
|
||||||
Test ISR FIFO (invoked from Task) - put 001056dc and get back 001056dc
|
Test ISR FIFO (invoked from Task) - put 001056dc and get back 001056dc
|
||||||
PASS - testIsrFifoFromTask.
|
PASS - testIsrFifoFromTask.
|
||||||
===================================================================
|
===================================================================
|
||||||
test nano_task_fifo_get_wait_timeout with timeout > 0
|
test nano_task_fifo_get with timeout > 0
|
||||||
nano_task_fifo_get_wait_timeout timed out as expected
|
nano_task_fifo_get timed out as expected
|
||||||
nano_task_fifo_get_wait_timeout got fifo in time, as expected
|
nano_task_fifo_get got fifo in time, as expected
|
||||||
testing timeouts of 5 fibers on same fifo
|
testing timeouts of 5 fibers on same fifo
|
||||||
got fiber (q order: 2, t/o: 10, fifo 200049c0) as expected
|
got fiber (q order: 2, t/o: 10, fifo 200049c0) as expected
|
||||||
got fiber (q order: 3, t/o: 15, fifo 200049c0) as expected
|
got fiber (q order: 3, t/o: 15, fifo 200049c0) as expected
|
||||||
|
|
|
@ -21,10 +21,9 @@
|
||||||
* This module tests four basic scenarios with the usage of the following FIFO
|
* This module tests four basic scenarios with the usage of the following FIFO
|
||||||
* routines:
|
* routines:
|
||||||
*
|
*
|
||||||
* nano_fiber_fifo_get, nano_fiber_fifo_get_wait, nano_fiber_fifo_put
|
* nano_fiber_fifo_get, nano_fiber_fifo_put
|
||||||
* nano_task_fifo_get, nano_task_fifo_get_wait, nano_task_fifo_put
|
* nano_task_fifo_get, nano_task_fifo_put
|
||||||
* nano_isr_fifo_get, nano_isr_fifo_put
|
* nano_isr_fifo_get, nano_isr_fifo_put
|
||||||
* nano_fiber_fifo_take_wait_timeout, nano_task_fifo_take_wait_timeout
|
|
||||||
*
|
*
|
||||||
* Scenario #1
|
* Scenario #1
|
||||||
* Task enters items into a queue, starts the fiber and waits for a semaphore.
|
* Task enters items into a queue, starts the fiber and waits for a semaphore.
|
||||||
|
@ -167,7 +166,7 @@ void isr_fifo_get(void *parameter)
|
||||||
{
|
{
|
||||||
ISR_FIFO_INFO *pInfo = (ISR_FIFO_INFO *) parameter;
|
ISR_FIFO_INFO *pInfo = (ISR_FIFO_INFO *) parameter;
|
||||||
|
|
||||||
pInfo->data = nano_isr_fifo_get(pInfo->fifo_ptr);
|
pInfo->data = nano_isr_fifo_get(pInfo->fifo_ptr, TICKS_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _trigger_nano_isr_fifo_get(void)
|
static void _trigger_nano_isr_fifo_get(void)
|
||||||
|
@ -191,7 +190,7 @@ void fiber1(void)
|
||||||
nano_fiber_sem_take_wait(&nanoSemObj1);
|
nano_fiber_sem_take_wait(&nanoSemObj1);
|
||||||
|
|
||||||
/* Wait for data to be added to <nanoFifoObj> by task */
|
/* Wait for data to be added to <nanoFifoObj> by task */
|
||||||
pData = nano_fiber_fifo_get_wait(&nanoFifoObj);
|
pData = nano_fiber_fifo_get(&nanoFifoObj, TICKS_UNLIMITED);
|
||||||
if (pData != pPutList1[0]) {
|
if (pData != pPutList1[0]) {
|
||||||
TC_ERROR("fiber1 (1) - expected 0x%x, got 0x%x\n",
|
TC_ERROR("fiber1 (1) - expected 0x%x, got 0x%x\n",
|
||||||
pPutList1[0], pData);
|
pPutList1[0], pData);
|
||||||
|
@ -200,7 +199,7 @@ void fiber1(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for data to be added to <nanoFifoObj2> by fiber3 */
|
/* Wait for data to be added to <nanoFifoObj2> by fiber3 */
|
||||||
pData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
|
pData = nano_fiber_fifo_get(&nanoFifoObj2, TICKS_UNLIMITED);
|
||||||
if (pData != pPutList2[0]) {
|
if (pData != pPutList2[0]) {
|
||||||
TC_ERROR("fiber1 (2) - expected 0x%x, got 0x%x\n",
|
TC_ERROR("fiber1 (2) - expected 0x%x, got 0x%x\n",
|
||||||
pPutList2[0], pData);
|
pPutList2[0], pData);
|
||||||
|
@ -212,7 +211,7 @@ void fiber1(void)
|
||||||
|
|
||||||
TC_PRINT("Test Fiber FIFO Get\n\n");
|
TC_PRINT("Test Fiber FIFO Get\n\n");
|
||||||
/* Get all FIFOs */
|
/* Get all FIFOs */
|
||||||
while ((pData = nano_fiber_fifo_get(&nanoFifoObj)) != NULL) {
|
while ((pData = nano_fiber_fifo_get(&nanoFifoObj, TICKS_NONE)) != NULL) {
|
||||||
TC_PRINT("FIBER FIFO Get: count = %d, ptr is %p\n", count, pData);
|
TC_PRINT("FIBER FIFO Get: count = %d, ptr is %p\n", count, pData);
|
||||||
if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) {
|
if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) {
|
||||||
TCERR1(count);
|
TCERR1(count);
|
||||||
|
@ -246,7 +245,7 @@ void fiber1(void)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Test the nano_fiber_fifo_get_wait() interface
|
* @brief Test the nano_fiber_fifo_get(TICKS_UNLIMITED) interface
|
||||||
*
|
*
|
||||||
* This function tests the fifo put and get wait interfaces in a fiber.
|
* This function tests the fifo put and get wait interfaces in a fiber.
|
||||||
* It gets data from nanoFifoObj2 queue and puts data to nanoFifoObj queue.
|
* It gets data from nanoFifoObj2 queue and puts data to nanoFifoObj queue.
|
||||||
|
@ -260,7 +259,7 @@ void testFiberFifoGetW(void)
|
||||||
void *pPutData; /* pointer to FIFO object to put to the queue */
|
void *pPutData; /* pointer to FIFO object to put to the queue */
|
||||||
|
|
||||||
TC_PRINT("Test Fiber FIFO Get Wait Interfaces\n\n");
|
TC_PRINT("Test Fiber FIFO Get Wait Interfaces\n\n");
|
||||||
pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
|
pGetData = nano_fiber_fifo_get(&nanoFifoObj2, TICKS_UNLIMITED);
|
||||||
TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData);
|
TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData);
|
||||||
/* Verify results */
|
/* Verify results */
|
||||||
if (pGetData != pMyFifoData1) {
|
if (pGetData != pMyFifoData1) {
|
||||||
|
@ -273,7 +272,7 @@ void testFiberFifoGetW(void)
|
||||||
TC_PRINT("FIBER FIFO Put to queue1: %p\n", pPutData);
|
TC_PRINT("FIBER FIFO Put to queue1: %p\n", pPutData);
|
||||||
nano_fiber_fifo_put(&nanoFifoObj, pPutData);
|
nano_fiber_fifo_put(&nanoFifoObj, pPutData);
|
||||||
|
|
||||||
pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
|
pGetData = nano_fiber_fifo_get(&nanoFifoObj2, TICKS_UNLIMITED);
|
||||||
TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData);
|
TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData);
|
||||||
/* Verify results */
|
/* Verify results */
|
||||||
if (pGetData != pMyFifoData3) {
|
if (pGetData != pMyFifoData3) {
|
||||||
|
@ -424,7 +423,7 @@ void fiber2(void)
|
||||||
nano_fiber_sem_take_wait(&nanoSemObj2);
|
nano_fiber_sem_take_wait(&nanoSemObj2);
|
||||||
|
|
||||||
/* Wait for data to be added to <nanoFifoObj> */
|
/* Wait for data to be added to <nanoFifoObj> */
|
||||||
pData = nano_fiber_fifo_get_wait(&nanoFifoObj);
|
pData = nano_fiber_fifo_get(&nanoFifoObj, TICKS_UNLIMITED);
|
||||||
if (pData != pPutList1[1]) {
|
if (pData != pPutList1[1]) {
|
||||||
TC_ERROR("fiber2 (1) - expected 0x%x, got 0x%x\n",
|
TC_ERROR("fiber2 (1) - expected 0x%x, got 0x%x\n",
|
||||||
pPutList1[1], pData);
|
pPutList1[1], pData);
|
||||||
|
@ -433,7 +432,7 @@ void fiber2(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for data to be added to <nanoFifoObj2> by fiber3 */
|
/* Wait for data to be added to <nanoFifoObj2> by fiber3 */
|
||||||
pData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
|
pData = nano_fiber_fifo_get(&nanoFifoObj2, TICKS_UNLIMITED);
|
||||||
if (pData != pPutList2[1]) {
|
if (pData != pPutList2[1]) {
|
||||||
TC_ERROR("fiber2 (2) - expected 0x%x, got 0x%x\n",
|
TC_ERROR("fiber2 (2) - expected 0x%x, got 0x%x\n",
|
||||||
pPutList2[1], pData);
|
pPutList2[1], pData);
|
||||||
|
@ -445,7 +444,7 @@ void fiber2(void)
|
||||||
|
|
||||||
/* Fiber #2 has been reactivated by main task */
|
/* Fiber #2 has been reactivated by main task */
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
pData = nano_fiber_fifo_get_wait(&nanoFifoObj);
|
pData = nano_fiber_fifo_get(&nanoFifoObj, TICKS_UNLIMITED);
|
||||||
if (pData != pPutList1[i]) {
|
if (pData != pPutList1[i]) {
|
||||||
TC_ERROR("fiber2 (3) - iteration %d expected 0x%x, got 0x%x\n",
|
TC_ERROR("fiber2 (3) - iteration %d expected 0x%x, got 0x%x\n",
|
||||||
i, pPutList1[i], pData);
|
i, pPutList1[i], pData);
|
||||||
|
@ -486,7 +485,7 @@ void fiber3(void)
|
||||||
nano_fiber_sem_take_wait(&nanoSemObj3);
|
nano_fiber_sem_take_wait(&nanoSemObj3);
|
||||||
|
|
||||||
/* Immediately get the data from <nanoFifoObj2>. */
|
/* Immediately get the data from <nanoFifoObj2>. */
|
||||||
pData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
|
pData = nano_fiber_fifo_get(&nanoFifoObj2, TICKS_UNLIMITED);
|
||||||
if (pData != pPutList2[0]) {
|
if (pData != pPutList2[0]) {
|
||||||
retCode = TC_FAIL;
|
retCode = TC_FAIL;
|
||||||
TC_ERROR("fiber3 (1) - got 0x%x from <nanoFifoObj2>, expected 0x%x\n",
|
TC_ERROR("fiber3 (1) - got 0x%x from <nanoFifoObj2>, expected 0x%x\n",
|
||||||
|
@ -512,7 +511,7 @@ void fiber3(void)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Test the nano_task_fifo_get_wait() interface
|
* @brief Test the nano_task_fifo_get(TICKS_UNLIMITED) interface
|
||||||
*
|
*
|
||||||
* This is in a task. It puts data to nanoFifoObj2 queue and gets
|
* This is in a task. It puts data to nanoFifoObj2 queue and gets
|
||||||
* data from nanoFifoObj queue.
|
* data from nanoFifoObj queue.
|
||||||
|
@ -534,7 +533,7 @@ void testTaskFifoGetW(void)
|
||||||
/* Activate fiber2 */
|
/* Activate fiber2 */
|
||||||
nano_task_sem_give(&nanoSemObj2);
|
nano_task_sem_give(&nanoSemObj2);
|
||||||
|
|
||||||
pGetData = nano_task_fifo_get_wait(&nanoFifoObj);
|
pGetData = nano_task_fifo_get(&nanoFifoObj, TICKS_UNLIMITED);
|
||||||
TC_PRINT("TASK FIFO Get from queue1: %p\n", pGetData);
|
TC_PRINT("TASK FIFO Get from queue1: %p\n", pGetData);
|
||||||
/* Verify results */
|
/* Verify results */
|
||||||
if (pGetData != pMyFifoData2) {
|
if (pGetData != pMyFifoData2) {
|
||||||
|
@ -629,9 +628,9 @@ void main(void)
|
||||||
nano_task_sem_give(&nanoSemObj3); /* Reactivate fiber #3 */
|
nano_task_sem_give(&nanoSemObj3); /* Reactivate fiber #3 */
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
pData = nano_task_fifo_get_wait(&nanoFifoObj2);
|
pData = nano_task_fifo_get(&nanoFifoObj2, TICKS_UNLIMITED);
|
||||||
if (pData != pPutList2[i]) {
|
if (pData != pPutList2[i]) {
|
||||||
TC_ERROR("nano_task_fifo_get_wait() expected 0x%x, got 0x%x\n",
|
TC_ERROR("nano_task_fifo_get() expected 0x%x, got 0x%x\n",
|
||||||
pPutList2[i], pData);
|
pPutList2[i], pData);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -681,7 +680,7 @@ void main(void)
|
||||||
TC_PRINT("Test Task FIFO Get\n");
|
TC_PRINT("Test Task FIFO Get\n");
|
||||||
|
|
||||||
/* Get all FIFOs */
|
/* Get all FIFOs */
|
||||||
while ((pData = nano_task_fifo_get(&nanoFifoObj)) != NULL) {
|
while ((pData = nano_task_fifo_get(&nanoFifoObj, TICKS_NONE)) != NULL) {
|
||||||
TC_PRINT("TASK FIFO Get: count = %d, ptr is %p\n", count, pData);
|
TC_PRINT("TASK FIFO Get: count = %d, ptr is %p\n", count, pData);
|
||||||
if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList2[count])) {
|
if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList2[count])) {
|
||||||
TCERR1(count);
|
TCERR1(count);
|
||||||
|
|
|
@ -59,7 +59,7 @@ struct nano_fifo scratch_fifo_packets_fifo;
|
||||||
|
|
||||||
void *get_scratch_packet(void)
|
void *get_scratch_packet(void)
|
||||||
{
|
{
|
||||||
void *packet = nano_fifo_get(&scratch_fifo_packets_fifo);
|
void *packet = nano_fifo_get(&scratch_fifo_packets_fifo, TICKS_NONE);
|
||||||
|
|
||||||
__ASSERT_NO_MSG(packet);
|
__ASSERT_NO_MSG(packet);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ static void test_fiber_pend_and_timeout(int data, int unused)
|
||||||
|
|
||||||
ARG_UNUSED(unused);
|
ARG_UNUSED(unused);
|
||||||
|
|
||||||
packet = nano_fiber_fifo_get_wait_timeout(d->fifo, d->timeout);
|
packet = nano_fiber_fifo_get(d->fifo, d->timeout);
|
||||||
if (packet) {
|
if (packet) {
|
||||||
TC_ERROR(" *** timeout of %d did not time out.\n",
|
TC_ERROR(" *** timeout of %d did not time out.\n",
|
||||||
d->timeout);
|
d->timeout);
|
||||||
|
@ -150,7 +150,7 @@ static int test_multiple_fibers_pending(struct timeout_order_data *test_data,
|
||||||
|
|
||||||
for (ii = 0; ii < test_data_size; ii++) {
|
for (ii = 0; ii < test_data_size; ii++) {
|
||||||
struct timeout_order_data *data =
|
struct timeout_order_data *data =
|
||||||
nano_task_fifo_get_wait(&timeout_order_fifo);
|
nano_task_fifo_get(&timeout_order_fifo, TICKS_UNLIMITED);
|
||||||
|
|
||||||
if (data->timeout_order == ii) {
|
if (data->timeout_order == ii) {
|
||||||
TC_PRINT(" got fiber (q order: %d, t/o: %d, fifo %p) as expected\n",
|
TC_PRINT(" got fiber (q order: %d, t/o: %d, fifo %p) as expected\n",
|
||||||
|
@ -173,7 +173,7 @@ static void test_fiber_pend_and_get_data(int data, int unused)
|
||||||
|
|
||||||
ARG_UNUSED(unused);
|
ARG_UNUSED(unused);
|
||||||
|
|
||||||
packet = nano_fiber_fifo_get_wait_timeout(d->fifo, d->timeout);
|
packet = nano_fiber_fifo_get(d->fifo, d->timeout);
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
TC_PRINT(" *** fiber (q order: %d, t/o: %d, fifo %p) timed out!\n",
|
TC_PRINT(" *** fiber (q order: %d, t/o: %d, fifo %p) timed out!\n",
|
||||||
d->q_order, d->timeout, d->fifo);
|
d->q_order, d->timeout, d->fifo);
|
||||||
|
@ -206,7 +206,7 @@ static int test_multiple_fibers_get_data(struct timeout_order_data *test_data,
|
||||||
|
|
||||||
nano_task_fifo_put(test_data[ii].fifo, get_scratch_packet());
|
nano_task_fifo_put(test_data[ii].fifo, get_scratch_packet());
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait(&timeout_order_fifo);
|
data = nano_task_fifo_get(&timeout_order_fifo, TICKS_UNLIMITED);
|
||||||
|
|
||||||
if (data->q_order == ii) {
|
if (data->q_order == ii) {
|
||||||
TC_PRINT(" got fiber (q order: %d, t/o: %d, fifo %p) as expected\n",
|
TC_PRINT(" got fiber (q order: %d, t/o: %d, fifo %p) as expected\n",
|
||||||
|
@ -218,7 +218,7 @@ static int test_multiple_fibers_get_data(struct timeout_order_data *test_data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait(&timeout_order_fifo);
|
data = nano_task_fifo_get(&timeout_order_fifo, TICKS_UNLIMITED);
|
||||||
if (data->q_order == ii) {
|
if (data->q_order == ii) {
|
||||||
TC_PRINT(" got fiber (q order: %d, t/o: %d, fifo %p) as expected\n",
|
TC_PRINT(" got fiber (q order: %d, t/o: %d, fifo %p) as expected\n",
|
||||||
data->q_order, data->timeout, data->fifo);
|
data->q_order, data->timeout, data->fifo);
|
||||||
|
@ -237,7 +237,7 @@ static void test_fiber_ticks_special_values(int packet, int special_value)
|
||||||
struct reply_packet *reply_packet = (void *)packet;
|
struct reply_packet *reply_packet = (void *)packet;
|
||||||
|
|
||||||
reply_packet->reply =
|
reply_packet->reply =
|
||||||
!!nano_fiber_fifo_get_wait_timeout(&fifo_timeout[0], special_value);
|
!!nano_fiber_fifo_get(&fifo_timeout[0], special_value);
|
||||||
|
|
||||||
nano_fiber_fifo_put(&timeout_order_fifo, reply_packet);
|
nano_fiber_fifo_put(&timeout_order_fifo, reply_packet);
|
||||||
}
|
}
|
||||||
|
@ -264,10 +264,10 @@ int test_fifo_timeout(void)
|
||||||
&scratch_fifo_packets[ii]);
|
&scratch_fifo_packets[ii]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test nano_task_fifo_get_wait_timeout() with timeout */
|
/* test nano_task_fifo_get() with timeout */
|
||||||
timeout = 10;
|
timeout = 10;
|
||||||
orig_ticks = sys_tick_get();
|
orig_ticks = sys_tick_get();
|
||||||
packet = nano_task_fifo_get_wait_timeout(&fifo_timeout[0], timeout);
|
packet = nano_task_fifo_get(&fifo_timeout[0], timeout);
|
||||||
if (packet) {
|
if (packet) {
|
||||||
TC_ERROR(" *** timeout of %d did not time out.\n", timeout);
|
TC_ERROR(" *** timeout of %d did not time out.\n", timeout);
|
||||||
TC_END_RESULT(TC_FAIL);
|
TC_END_RESULT(TC_FAIL);
|
||||||
|
@ -280,23 +280,23 @@ int test_fifo_timeout(void)
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test nano_task_fifo_get_wait_timeout with timeout of 0 */
|
/* test nano_task_fifo_get with timeout of 0 */
|
||||||
|
|
||||||
packet = nano_task_fifo_get_wait_timeout(&fifo_timeout[0], 0);
|
packet = nano_task_fifo_get(&fifo_timeout[0], 0);
|
||||||
if (packet) {
|
if (packet) {
|
||||||
TC_ERROR(" *** timeout of 0 did not time out.\n");
|
TC_ERROR(" *** timeout of 0 did not time out.\n");
|
||||||
TC_END_RESULT(TC_FAIL);
|
TC_END_RESULT(TC_FAIL);
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test nano_task_fifo_get_wait_timeout with timeout > 0 */
|
/* test nano_task_fifo_get with timeout > 0 */
|
||||||
|
|
||||||
TC_PRINT("test nano_task_fifo_get_wait_timeout with timeout > 0\n");
|
TC_PRINT("test nano_task_fifo_get with timeout > 0\n");
|
||||||
|
|
||||||
timeout = 3;
|
timeout = 3;
|
||||||
orig_ticks = sys_tick_get();
|
orig_ticks = sys_tick_get();
|
||||||
|
|
||||||
packet = nano_task_fifo_get_wait_timeout(&fifo_timeout[0], timeout);
|
packet = nano_task_fifo_get(&fifo_timeout[0], timeout);
|
||||||
|
|
||||||
if (packet) {
|
if (packet) {
|
||||||
TC_ERROR(" *** timeout of %d did not time out.\n",
|
TC_ERROR(" *** timeout of %d did not time out.\n",
|
||||||
|
@ -310,10 +310,10 @@ int test_fifo_timeout(void)
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TC_PRINT("nano_task_fifo_get_wait_timeout timed out as expected\n");
|
TC_PRINT("nano_task_fifo_get timed out as expected\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test nano_task_fifo_get_wait_timeout with a timeout and fiber that puts
|
* test nano_task_fifo_get with a timeout and fiber that puts
|
||||||
* data on the fifo on time
|
* data on the fifo on time
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ int test_fifo_timeout(void)
|
||||||
timeout,
|
timeout,
|
||||||
FIBER_PRIORITY, 0);
|
FIBER_PRIORITY, 0);
|
||||||
|
|
||||||
packet = nano_task_fifo_get_wait_timeout(&fifo_timeout[0],
|
packet = nano_task_fifo_get(&fifo_timeout[0],
|
||||||
(int)(timeout + 5));
|
(int)(timeout + 5));
|
||||||
if (!packet) {
|
if (!packet) {
|
||||||
TC_ERROR(" *** data put in time did not return valid pointer.\n");
|
TC_ERROR(" *** data put in time did not return valid pointer.\n");
|
||||||
|
@ -340,14 +340,14 @@ int test_fifo_timeout(void)
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TC_PRINT("nano_task_fifo_get_wait_timeout got fifo in time, as expected\n");
|
TC_PRINT("nano_task_fifo_get got fifo in time, as expected\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test nano_task_fifo_get_wait_timeout with TICKS_NONE and no data
|
* test nano_task_fifo_get with TICKS_NONE and no data
|
||||||
* unavailable.
|
* unavailable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (nano_task_fifo_get_wait_timeout(&fifo_timeout[0], TICKS_NONE)) {
|
if (nano_task_fifo_get(&fifo_timeout[0], TICKS_NONE)) {
|
||||||
TC_ERROR("task with TICKS_NONE got data, but shouldn't have\n");
|
TC_ERROR("task with TICKS_NONE got data, but shouldn't have\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -355,13 +355,13 @@ int test_fifo_timeout(void)
|
||||||
TC_PRINT("task with TICKS_NONE did not get data, as expected\n");
|
TC_PRINT("task with TICKS_NONE did not get data, as expected\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test nano_task_fifo_get_wait_timeout with TICKS_NONE and some data
|
* test nano_task_fifo_get with TICKS_NONE and some data
|
||||||
* available.
|
* available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
scratch_packet = get_scratch_packet();
|
scratch_packet = get_scratch_packet();
|
||||||
nano_task_fifo_put(&fifo_timeout[0], scratch_packet);
|
nano_task_fifo_put(&fifo_timeout[0], scratch_packet);
|
||||||
if (!nano_task_fifo_get_wait_timeout(&fifo_timeout[0], TICKS_NONE)) {
|
if (!nano_task_fifo_get(&fifo_timeout[0], TICKS_NONE)) {
|
||||||
TC_ERROR("task with TICKS_NONE did not get available data\n");
|
TC_ERROR("task with TICKS_NONE did not get available data\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -370,7 +370,7 @@ int test_fifo_timeout(void)
|
||||||
TC_PRINT("task with TICKS_NONE got available data, as expected\n");
|
TC_PRINT("task with TICKS_NONE got available data, as expected\n");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* test nano_task_fifo_get_wait_timeout with TICKS_UNLIMITED and the
|
* test nano_task_fifo_get with TICKS_UNLIMITED and the
|
||||||
* data available.
|
* data available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ int test_fifo_timeout(void)
|
||||||
|
|
||||||
scratch_packet = get_scratch_packet();
|
scratch_packet = get_scratch_packet();
|
||||||
nano_task_fifo_put(&fifo_timeout[0], scratch_packet);
|
nano_task_fifo_put(&fifo_timeout[0], scratch_packet);
|
||||||
if (!nano_task_fifo_get_wait_timeout(&fifo_timeout[0], TICKS_UNLIMITED)) {
|
if (!nano_task_fifo_get(&fifo_timeout[0], TICKS_UNLIMITED)) {
|
||||||
TC_ERROR(" *** This will never be hit!!! .\n");
|
TC_ERROR(" *** This will never be hit!!! .\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,7 @@ int test_fifo_timeout(void)
|
||||||
test_fiber_ticks_special_values,
|
test_fiber_ticks_special_values,
|
||||||
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
||||||
|
|
||||||
if (!nano_task_fifo_get(&timeout_order_fifo)) {
|
if (!nano_task_fifo_get(&timeout_order_fifo, TICKS_NONE)) {
|
||||||
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,7 @@ int test_fifo_timeout(void)
|
||||||
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
||||||
put_scratch_packet(scratch_packet);
|
put_scratch_packet(scratch_packet);
|
||||||
|
|
||||||
if (!nano_task_fifo_get(&timeout_order_fifo)) {
|
if (!nano_task_fifo_get(&timeout_order_fifo, TICKS_NONE)) {
|
||||||
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ int test_fifo_timeout(void)
|
||||||
(int)&reply_packet, TICKS_UNLIMITED, FIBER_PRIORITY, 0);
|
(int)&reply_packet, TICKS_UNLIMITED, FIBER_PRIORITY, 0);
|
||||||
put_scratch_packet(scratch_packet);
|
put_scratch_packet(scratch_packet);
|
||||||
|
|
||||||
if (!nano_task_fifo_get(&timeout_order_fifo)) {
|
if (!nano_task_fifo_get(&timeout_order_fifo, TICKS_NONE)) {
|
||||||
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -616,7 +616,7 @@ struct nano_fifo scratch_q_packets_fifo;
|
||||||
|
|
||||||
void *get_scratch_packet(void)
|
void *get_scratch_packet(void)
|
||||||
{
|
{
|
||||||
void *packet = nano_fifo_get(&scratch_q_packets_fifo);
|
void *packet = nano_fifo_get(&scratch_q_packets_fifo, TICKS_NONE);
|
||||||
|
|
||||||
__ASSERT_NO_MSG(packet);
|
__ASSERT_NO_MSG(packet);
|
||||||
|
|
||||||
|
@ -706,7 +706,7 @@ static int test_multiple_fibers_pending(struct timeout_order_data *test_data,
|
||||||
|
|
||||||
for (ii = 0; ii < test_data_size; ii++) {
|
for (ii = 0; ii < test_data_size; ii++) {
|
||||||
struct timeout_order_data *data =
|
struct timeout_order_data *data =
|
||||||
nano_task_fifo_get_wait(&timeout_order_fifo);
|
nano_task_fifo_get(&timeout_order_fifo, TICKS_UNLIMITED);
|
||||||
|
|
||||||
if (data->timeout_order == ii) {
|
if (data->timeout_order == ii) {
|
||||||
TC_PRINT(" got fiber (q order: %d, t/o: %d, lifo %p) as expected\n",
|
TC_PRINT(" got fiber (q order: %d, t/o: %d, lifo %p) as expected\n",
|
||||||
|
@ -762,7 +762,7 @@ static int test_multiple_fibers_get_data(struct timeout_order_data *test_data,
|
||||||
|
|
||||||
nano_task_lifo_put(test_data[ii].lifo, get_scratch_packet());
|
nano_task_lifo_put(test_data[ii].lifo, get_scratch_packet());
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait(&timeout_order_fifo);
|
data = nano_task_fifo_get(&timeout_order_fifo, TICKS_UNLIMITED);
|
||||||
|
|
||||||
if (data->q_order == ii) {
|
if (data->q_order == ii) {
|
||||||
TC_PRINT(" got fiber (q order: %d, t/o: %d, lifo %p) as expected\n",
|
TC_PRINT(" got fiber (q order: %d, t/o: %d, lifo %p) as expected\n",
|
||||||
|
@ -774,7 +774,7 @@ static int test_multiple_fibers_get_data(struct timeout_order_data *test_data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait(&timeout_order_fifo);
|
data = nano_task_fifo_get(&timeout_order_fifo, TICKS_UNLIMITED);
|
||||||
if (data->q_order == ii) {
|
if (data->q_order == ii) {
|
||||||
TC_PRINT(" got fiber (q order: %d, t/o: %d, lifo %p) as expected\n",
|
TC_PRINT(" got fiber (q order: %d, t/o: %d, lifo %p) as expected\n",
|
||||||
data->q_order, data->timeout, data->lifo);
|
data->q_order, data->timeout, data->lifo);
|
||||||
|
@ -942,7 +942,7 @@ static int test_timeout(void)
|
||||||
test_fiber_ticks_special_values,
|
test_fiber_ticks_special_values,
|
||||||
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
||||||
|
|
||||||
if (!nano_task_fifo_get(&timeout_order_fifo)) {
|
if (!nano_task_fifo_get(&timeout_order_fifo, TICKS_NONE)) {
|
||||||
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -963,7 +963,7 @@ static int test_timeout(void)
|
||||||
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
||||||
put_scratch_packet(scratch_packet);
|
put_scratch_packet(scratch_packet);
|
||||||
|
|
||||||
if (!nano_task_fifo_get(&timeout_order_fifo)) {
|
if (!nano_task_fifo_get(&timeout_order_fifo, TICKS_NONE)) {
|
||||||
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -984,7 +984,7 @@ static int test_timeout(void)
|
||||||
(int)&reply_packet, TICKS_UNLIMITED, FIBER_PRIORITY, 0);
|
(int)&reply_packet, TICKS_UNLIMITED, FIBER_PRIORITY, 0);
|
||||||
put_scratch_packet(scratch_packet);
|
put_scratch_packet(scratch_packet);
|
||||||
|
|
||||||
if (!nano_task_fifo_get(&timeout_order_fifo)) {
|
if (!nano_task_fifo_get(&timeout_order_fifo, TICKS_NONE)) {
|
||||||
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -605,7 +605,7 @@ static int test_multiple_fibers_pending(struct timeout_order_data *test_data,
|
||||||
|
|
||||||
for (ii = 0; ii < test_data_size; ii++) {
|
for (ii = 0; ii < test_data_size; ii++) {
|
||||||
struct timeout_order_data *data =
|
struct timeout_order_data *data =
|
||||||
nano_task_fifo_get_wait(&timeout_order_fifo);
|
nano_task_fifo_get(&timeout_order_fifo, TICKS_UNLIMITED);
|
||||||
|
|
||||||
if (data->timeout_order == ii) {
|
if (data->timeout_order == ii) {
|
||||||
TC_PRINT(" got fiber (q order: %d, t/o: %d, sem: %p) as expected\n",
|
TC_PRINT(" got fiber (q order: %d, t/o: %d, sem: %p) as expected\n",
|
||||||
|
@ -659,7 +659,7 @@ static int test_multiple_fibers_get_sem(struct timeout_order_data *test_data,
|
||||||
for (ii = 0; ii < test_data_size-1; ii++) {
|
for (ii = 0; ii < test_data_size-1; ii++) {
|
||||||
nano_task_sem_give(test_data[ii].sem);
|
nano_task_sem_give(test_data[ii].sem);
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait(&timeout_order_fifo);
|
data = nano_task_fifo_get(&timeout_order_fifo, TICKS_UNLIMITED);
|
||||||
|
|
||||||
if (data->q_order == ii) {
|
if (data->q_order == ii) {
|
||||||
TC_PRINT(" got fiber (q order: %d, t/o: %d, sem: %p) as expected\n",
|
TC_PRINT(" got fiber (q order: %d, t/o: %d, sem: %p) as expected\n",
|
||||||
|
@ -671,7 +671,7 @@ static int test_multiple_fibers_get_sem(struct timeout_order_data *test_data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data = nano_task_fifo_get_wait(&timeout_order_fifo);
|
data = nano_task_fifo_get(&timeout_order_fifo, TICKS_UNLIMITED);
|
||||||
if (data->q_order == ii) {
|
if (data->q_order == ii) {
|
||||||
TC_PRINT(" got fiber (q order: %d, t/o: %d, sem: %p) as expected\n",
|
TC_PRINT(" got fiber (q order: %d, t/o: %d, sem: %p) as expected\n",
|
||||||
data->q_order, data->timeout, data->sem);
|
data->q_order, data->timeout, data->sem);
|
||||||
|
@ -821,7 +821,7 @@ static int test_timeout(void)
|
||||||
test_fiber_ticks_special_values,
|
test_fiber_ticks_special_values,
|
||||||
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
||||||
|
|
||||||
if (!nano_task_fifo_get(&timeout_order_fifo)) {
|
if (!nano_task_fifo_get(&timeout_order_fifo, TICKS_NONE)) {
|
||||||
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -841,7 +841,7 @@ static int test_timeout(void)
|
||||||
test_fiber_ticks_special_values,
|
test_fiber_ticks_special_values,
|
||||||
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
(int)&reply_packet, TICKS_NONE, FIBER_PRIORITY, 0);
|
||||||
|
|
||||||
if (!nano_task_fifo_get(&timeout_order_fifo)) {
|
if (!nano_task_fifo_get(&timeout_order_fifo, TICKS_NONE)) {
|
||||||
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ static int test_timeout(void)
|
||||||
test_fiber_ticks_special_values,
|
test_fiber_ticks_special_values,
|
||||||
(int)&reply_packet, TICKS_UNLIMITED, FIBER_PRIORITY, 0);
|
(int)&reply_packet, TICKS_UNLIMITED, FIBER_PRIORITY, 0);
|
||||||
|
|
||||||
if (!nano_task_fifo_get(&timeout_order_fifo)) {
|
if (!nano_task_fifo_get(&timeout_order_fifo, TICKS_NONE)) {
|
||||||
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
TC_ERROR(" *** fiber should have run and filled the fifo.\n");
|
||||||
return TC_FAIL;
|
return TC_FAIL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue