![]() |
RT-Thread RTOS
An open source embedded real-time operating system
|
Collaboration diagram for Message Queue:Data Structures | |
| struct | rt_messagequeue |
Functions | |
| rt_err_t | rt_mq_init (rt_mq_t mq, const char *name, void *msgpool, rt_size_t msg_size, rt_size_t pool_size, rt_uint8_t flag) |
| rt_err_t | rt_mq_detach (rt_mq_t mq) |
| rt_mq_t | rt_mq_create (const char *name, rt_size_t msg_size, rt_size_t max_msgs, rt_uint8_t flag) |
| rt_err_t | rt_mq_delete (rt_mq_t mq) |
| rt_err_t | rt_mq_send (rt_mq_t mq, const void *buffer, rt_size_t size) |
| rt_err_t | rt_mq_urgent (rt_mq_t mq, const void *buffer, rt_size_t size) |
| rt_err_t | rt_mq_control (rt_mq_t mq, int cmd, void *arg) |
| rt_err_t rt_mq_init | ( | rt_mq_t | mq, |
| const char * | name, | ||
| void * | msgpool, | ||
| rt_size_t | msg_size, | ||
| rt_size_t | pool_size, | ||
| rt_uint8_t | flag | ||
| ) |
Initialize a static messagequeue object.
| mq | is a pointer to the messagequeue to initialize. It is assumed that storage for the messagequeue will be allocated in your application. |
| name | is a pointer to the name that given to the messagequeue. |
| msgpool | is a pointer to the starting address of the memory space you allocated for the messagequeue in advance. In other words, msgpool is a pointer to the messagequeue buffer of the starting address. |
| msg_size | is the maximum length of a message in the messagequeue (Unit: Byte). |
| pool_size | is the size of the memory space allocated for the messagequeue in advance. |
| flag | is the messagequeue flag, which determines the queuing way of how multiple threads wait when the messagequeue is not available. The messagequeue flag can be ONE of the following values: RT_IPC_FLAG_PRIO The pending threads will queue in order of priority.
RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method
(also known as first-come-first-served (FCFS) scheduling strategy).
NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to
use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about
the first-in-first-out principle, and you clearly understand that all threads involved in
this messagequeue will become non-real-time threads.
|
| rt_err_t rt_mq_detach | ( | rt_mq_t | mq | ) |
This function will detach a static messagequeue object.
| mq | is a pointer to a messagequeue object to be detached. |
| rt_mq_t rt_mq_create | ( | const char * | name, |
| rt_size_t | msg_size, | ||
| rt_size_t | max_msgs, | ||
| rt_uint8_t | flag | ||
| ) |
Creating a messagequeue object.
| name | is a pointer that given to the messagequeue. |
| msg_size | is the maximum length of a message in the messagequeue (Unit: Byte). |
| max_msgs | is the maximum number of messages in the messagequeue. |
| flag | is the messagequeue flag, which determines the queuing way of how multiple threads wait when the messagequeue is not available. The messagequeue flag can be ONE of the following values: RT_IPC_FLAG_PRIO The pending threads will queue in order of priority.
RT_IPC_FLAG_FIFO The pending threads will queue in the first-in-first-out method
(also known as first-come-first-served (FCFS) scheduling strategy).
NOTE: RT_IPC_FLAG_FIFO is a non-real-time scheduling mode. It is strongly recommended to
use RT_IPC_FLAG_PRIO to ensure the thread is real-time UNLESS your applications concern about
the first-in-first-out principle, and you clearly understand that all threads involved in
this messagequeue will become non-real-time threads.
|
| rt_err_t rt_mq_delete | ( | rt_mq_t | mq | ) |
This function will delete a messagequeue object and release the memory.
| mq | is a pointer to a messagequeue object to be deleted. |
| rt_err_t rt_mq_send | ( | rt_mq_t | mq, |
| const void * | buffer, | ||
| rt_size_t | size | ||
| ) |
This function will send a message to the messagequeue object. If there is a thread suspended on the messagequeue, the thread will be resumed.
| mq | is a pointer to the messagequeue object to be sent. |
| buffer | is the content of the message. |
| size | is the length of the message(Unit: Byte). |
| rt_err_t rt_mq_urgent | ( | rt_mq_t | mq, |
| const void * | buffer, | ||
| rt_size_t | size | ||
| ) |
This function will send an urgent message to the messagequeue object.
| mq | is a pointer to the messagequeue object to be sent. |
| buffer | is the content of the message. |
| size | is the length of the message(Unit: Byte). |
| rt_err_t rt_mq_control | ( | rt_mq_t | mq, |
| int | cmd, | ||
| void * | arg | ||
| ) |
This function will set some extra attributions of a messagequeue object.
| mq | is a pointer to a messagequeue object. |
| cmd | is a command used to configure some attributions of the messagequeue. |
| arg | is the argument of the function to execute the command. |