mm/iob: Replace the critical section with spin lock

Base on discusion: https://github.com/apache/nuttx/issues/10981

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2023-10-21 17:20:29 +08:00
committed by Petro Karashchenko
parent d5d4006c6b
commit 9e4a1be8d4
9 changed files with 34 additions and 21 deletions
+4 -4
View File
@@ -57,7 +57,7 @@ static FAR struct iob_qentry_s *iob_alloc_qcommitted(void)
* to protect the committed list: We disable interrupts very briefly.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_iob_lock);
/* Take the I/O buffer from the head of the committed list */
@@ -73,7 +73,7 @@ static FAR struct iob_qentry_s *iob_alloc_qcommitted(void)
iobq->qe_head = NULL; /* Nothing is contained */
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_iob_lock, flags);
return iobq;
}
@@ -199,7 +199,7 @@ FAR struct iob_qentry_s *iob_tryalloc_qentry(void)
* to protect the free list: We disable interrupts very briefly.
*/
flags = enter_critical_section();
flags = spin_lock_irqsave(&g_iob_lock);
iobq = g_iob_freeqlist;
if (iobq)
{
@@ -225,7 +225,7 @@ FAR struct iob_qentry_s *iob_tryalloc_qentry(void)
iobq->qe_head = NULL; /* Nothing is contained */
}
leave_critical_section(flags);
spin_unlock_irqrestore(&g_iob_lock, flags);
return iobq;
}