kernel: Add k_msgq_peek() API

Add an API to peek into a message queue and read the first message
without removing the message from the queue.

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
This commit is contained in:
Sathish Kuttan 2018-11-09 21:03:10 -08:00 committed by Anas Nashif
commit 3efd8e17bd

View file

@ -3327,6 +3327,23 @@ __syscall int k_msgq_put(struct k_msgq *q, void *data, s32_t timeout);
*/
__syscall int k_msgq_get(struct k_msgq *q, void *data, s32_t timeout);
/**
* @brief Peek/read a message from a message queue.
*
* This routine reads a message from message queue @a q in a "first in,
* first out" manner and leaves the message in the queue.
*
* @note Can be called by ISRs.
*
* @param q Address of the message queue.
* @param data Address of area to hold the message read from the queue.
*
* @retval 0 Message read.
* @retval -ENOMSG Returned when the queue has no message.
* @req K-MSGQ-002
*/
__syscall int k_msgq_peek(struct k_msgq *q, void *data);
/**
* @brief Purge a message queue.
*