mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user