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

Function rt_prio_queue_push

components/vbus/prio_queue.c:134–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132#endif
133
134rt_err_t rt_prio_queue_push(struct rt_prio_queue *que,
135 rt_uint8_t prio,
136 void *data,
137 rt_int32_t timeout)
138{
139 rt_base_t level;
140 struct rt_prio_queue_item *item;
141
142 RT_ASSERT(que);
143
144 if (prio >= RT_PRIO_QUEUE_PRIO_MAX)
145 return -RT_ERROR;
146
147 item = rt_mp_alloc(&que->pool, timeout);
148 if (item == RT_NULL)
149 return -RT_ENOMEM;
150
151 rt_memcpy(item+1, data, que->item_sz);
152 item->next = RT_NULL;
153
154 level = rt_hw_interrupt_disable();
155
156 _do_push(que, prio, item);
157
158 if (!rt_list_isempty(&(que->suspended_pop_list)))
159 {
160 rt_thread_t thread;
161
162 /* get thread entry */
163 thread = RT_THREAD_LIST_NODE_ENTRY(que->suspended_pop_list.next);
164 /* resume it */
165 rt_thread_resume(thread);
166 rt_hw_interrupt_enable(level);
167
168 /* perform a schedule */
169 rt_schedule();
170
171 return RT_EOK;
172 }
173
174 rt_hw_interrupt_enable(level);
175
176 return RT_EOK;
177}
178
179rt_err_t rt_prio_queue_pop(struct rt_prio_queue *que,
180 void *data,

Callers 1

rt_vbus_postFunction · 0.85

Calls 8

rt_mp_allocFunction · 0.85
rt_memcpyFunction · 0.85
_do_pushFunction · 0.85
rt_list_isemptyFunction · 0.85
rt_thread_resumeFunction · 0.85
rt_hw_interrupt_disableFunction · 0.50
rt_hw_interrupt_enableFunction · 0.50
rt_scheduleFunction · 0.50

Tested by

no test coverage detected