Revert "mm/iob: Replace the critical section with spin lock"

`g_iob_sem.semcount` is both manually changed in iob source code and api
nxsem_xxx.

nxsem related API uses critical_section to ensure sem value is modified
correctly. If iob using spin lock and modify sem value in the same time,
it's not safe.

This PR revert the spin lock change and uses critical section to align
with what nxsem uses.
This commit is contained in:
liguiding1
2023-12-13 17:24:07 +08:00
committed by Xiang Xiao
parent 1280ac845a
commit b4def16ac3
9 changed files with 23 additions and 36 deletions
+4 -4
View File
@@ -59,7 +59,7 @@ static FAR struct iob_qentry_s *iob_alloc_qcommitted(void)
* to protect the committed list: We disable interrupts very briefly.
*/
flags = spin_lock_irqsave(&g_iob_lock);
flags = enter_critical_section();
/* Take the I/O buffer from the head of the committed list */
@@ -75,7 +75,7 @@ static FAR struct iob_qentry_s *iob_alloc_qcommitted(void)
iobq->qe_head = NULL; /* Nothing is contained */
}
spin_unlock_irqrestore(&g_iob_lock, flags);
leave_critical_section(flags);
return iobq;
}
@@ -201,7 +201,7 @@ FAR struct iob_qentry_s *iob_tryalloc_qentry(void)
* to protect the free list: We disable interrupts very briefly.
*/
flags = spin_lock_irqsave(&g_iob_lock);
flags = enter_critical_section();
iobq = g_iob_freeqlist;
if (iobq)
{
@@ -227,7 +227,7 @@ FAR struct iob_qentry_s *iob_tryalloc_qentry(void)
iobq->qe_head = NULL; /* Nothing is contained */
}
spin_unlock_irqrestore(&g_iob_lock, flags);
leave_critical_section(flags);
return iobq;
}