RT-Thread RTOS
1.2.0
An open source embedded real-time operating system
|
Data Structures | |
struct | rt_mailbox |
Functions | |
rt_err_t | rt_mb_init (rt_mailbox_t mb, const char *name, void *msgpool, rt_size_t size, rt_uint8_t flag) |
rt_err_t | rt_mb_detach (rt_mailbox_t mb) |
rt_mailbox_t | rt_mb_create (const char *name, rt_size_t size, rt_uint8_t flag) |
rt_err_t | rt_mb_delete (rt_mailbox_t mb) |
rt_err_t | rt_mb_send (rt_mailbox_t mb, rt_ubase_t value) |
rt_err_t | rt_mb_urgent (rt_mailbox_t mb, rt_ubase_t value) |
rt_err_t | rt_mb_control (rt_mailbox_t mb, int cmd, void *arg) |
rt_err_t rt_mb_init | ( | rt_mailbox_t | mb, |
const char * | name, | ||
void * | msgpool, | ||
rt_size_t | size, | ||
rt_uint8_t | flag | ||
) |
Initialize a static mailbox object.
mb | is a pointer to the mailbox to initialize. It is assumed that storage for the mailbox will be allocated in your application. |
name | is a pointer to the name that given to the mailbox. |
msgpool | the begin address of buffer to save received mail. |
size | is the maximum number of mails in the mailbox. For example, when the mailbox buffer capacity is N, size is N/4. |
flag | is the mailbox flag, which determines the queuing way of how multiple threads wait when the mailbox is not available. The mailbox 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 mailbox will become non-real-time threads. |
rt_err_t rt_mb_detach | ( | rt_mailbox_t | mb | ) |
This function will detach a static mailbox object.
mb | is a pointer to a mailbox object to be detached. |
rt_mailbox_t rt_mb_create | ( | const char * | name, |
rt_size_t | size, | ||
rt_uint8_t | flag | ||
) |
Creating a mailbox object.
name | is a pointer that given to the mailbox. |
size | is the maximum number of mails in the mailbox. For example, when mailbox buffer capacity is N, size is N/4. |
flag | is the mailbox flag, which determines the queuing way of how multiple threads wait when the mailbox is not available. The mailbox 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 mailbox will become non-real-time threads. |
rt_err_t rt_mb_delete | ( | rt_mailbox_t | mb | ) |
This function will delete a mailbox object and release the memory space.
mb | is a pointer to a mailbox object to be deleted. |
rt_err_t rt_mb_send | ( | rt_mailbox_t | mb, |
rt_ubase_t | value | ||
) |
This function will send an mail to the mailbox object. If there is a thread suspended on the mailbox, the thread will be resumed.
mb | is a pointer to the mailbox object to be sent. |
value | is a value to the content of the mail you want to send. |
rt_err_t rt_mb_urgent | ( | rt_mailbox_t | mb, |
rt_ubase_t | value | ||
) |
This function will send an urgent mail to the mailbox object.
mb | is a pointer to the mailbox object to be sent. |
value | is the content of the mail you want to send. |
rt_err_t rt_mb_control | ( | rt_mailbox_t | mb, |
int | cmd, | ||
void * | arg | ||
) |
This function will set some extra attributions of a mailbox object.
mb | is a pointer to a mailbox object. |
cmd | is a command used to configure some attributions of the mailbox. |
arg | is the argument of the function to execute the command. |