mm: idle check heap use mm_trysemaphore
Change-Id: I92e1df572fa6cd801b10e5b06e7b04d450b3e3fb Signed-off-by: ligd <liguiding1@xiaomi.com> (cherry picked from commit bc9a5d1ca9656f6effd3a419cc2488586dfb1489)
This commit is contained in:
parent
646b229f74
commit
68d66148ad
@ -66,15 +66,13 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap)
|
|||||||
for (region = 0; region < heap_impl->mm_nregions; region++)
|
for (region = 0; region < heap_impl->mm_nregions; region++)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
irqstate_t flags = 0;
|
|
||||||
|
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
|
|
||||||
/* Visit each node in the region
|
/* Visit each node in the region
|
||||||
* Retake the semaphore for each region to reduce latencies
|
* Retake the semaphore for each region to reduce latencies
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (up_interrupt_context() || sched_idletask())
|
if (up_interrupt_context())
|
||||||
{
|
{
|
||||||
if (heap_impl->mm_counts_held)
|
if (heap_impl->mm_counts_held)
|
||||||
{
|
{
|
||||||
@ -84,8 +82,13 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap)
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
flags = enter_critical_section();
|
else if (sched_idletask())
|
||||||
|
{
|
||||||
|
if (mm_trysemaphore(heap))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -122,11 +125,7 @@ void mm_checkcorruption(FAR struct mm_heap_s *heap)
|
|||||||
|
|
||||||
assert(node == heap_impl->mm_heapend[region]);
|
assert(node == heap_impl->mm_heapend[region]);
|
||||||
|
|
||||||
if (up_interrupt_context() || sched_idletask())
|
if (!up_interrupt_context())
|
||||||
{
|
|
||||||
leave_critical_section(flags);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
mm_givesemaphore(heap);
|
mm_givesemaphore(heap);
|
||||||
}
|
}
|
||||||
|
@ -805,19 +805,20 @@ void nx_start(void)
|
|||||||
|
|
||||||
/* Check stack in idle thread */
|
/* Check stack in idle thread */
|
||||||
|
|
||||||
flags = enter_critical_section();
|
|
||||||
|
|
||||||
for (i = 0; i < CONFIG_MAX_TASKS && g_pidhash[i].tcb; i++)
|
for (i = 0; i < CONFIG_MAX_TASKS && g_pidhash[i].tcb; i++)
|
||||||
{
|
{
|
||||||
|
flags = enter_critical_section();
|
||||||
|
|
||||||
if (up_check_tcbstack_remain(g_pidhash[i].tcb) <= 0)
|
if (up_check_tcbstack_remain(g_pidhash[i].tcb) <= 0)
|
||||||
{
|
{
|
||||||
_alert("Stack check failed, pid %d, name %s\n",
|
_alert("Stack check failed, pid %d, name %s\n",
|
||||||
g_pidhash[i].tcb->pid, g_pidhash[i].tcb->name);
|
g_pidhash[i].tcb->pid, g_pidhash[i].tcb->name);
|
||||||
PANIC();
|
PANIC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check heap in idle thread */
|
/* Check heap in idle thread */
|
||||||
|
Loading…
Reference in New Issue
Block a user