MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _ipc_msg_alloc

Function _ipc_msg_alloc

components/lwp/lwp_ipc.c:65–83  ·  view source on GitHub ↗

* Allocate an IPC message from the statically-allocated array. */

Source from the content-addressed store, hash-verified

63 * Allocate an IPC message from the statically-allocated array.
64 */
65static rt_ipc_msg_t _ipc_msg_alloc(void)
66{
67 rt_ipc_msg_t p = (rt_ipc_msg_t)RT_NULL;
68 rt_base_t level;
69
70 level = rt_spin_lock_irqsave(&_msg_list_lock);
71 if (_ipc_msg_free_list) /* use the released chain first */
72 {
73 p = _ipc_msg_free_list;
74 _ipc_msg_free_list = (rt_ipc_msg_t)p->msg.sender; /* emtry payload as a pointer */
75 }
76 else if (rt_ipc_msg_used < RT_CH_MSG_MAX_NR)
77 {
78 p = &ipc_msg_pool[rt_ipc_msg_used];
79 rt_ipc_msg_used++;
80 }
81 rt_spin_unlock_irqrestore(&_msg_list_lock, level);
82 return p;
83}
84
85/**
86 * Put a released IPC message back to the released chain.

Callers 2

_send_recv_timeoutFunction · 0.85
rt_raw_channel_replyFunction · 0.85

Calls 2

rt_spin_lock_irqsaveFunction · 0.50

Tested by

no test coverage detected