Replace enter_critical_section with spin_irqsave
Base on discusion: https://github.com/apache/nuttx/issues/10981 Signed-off-by: TaiJuWu <tjwu1217@gmail.com>
This commit is contained in:
parent
3ad28c28aa
commit
51eaa59cc0
|
@ -47,12 +47,12 @@ static void free_delaylist(FAR struct mm_heap_s *heap)
|
|||
|
||||
/* Move the delay list to local */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(NULL);
|
||||
|
||||
tmp = heap->mm_delaylist[up_cpu_index()];
|
||||
heap->mm_delaylist[up_cpu_index()] = NULL;
|
||||
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(NULL, flags);
|
||||
|
||||
/* Test if the delayed is empty */
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <nuttx/irq.h>
|
||||
#include <nuttx/wdog.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
#include "timer/timer.h"
|
||||
|
||||
|
@ -59,10 +60,10 @@ static FAR struct posix_timer_s *timer_allocate(void)
|
|||
/* Try to get a preallocated timer from the free list */
|
||||
|
||||
#if CONFIG_PREALLOC_TIMERS > 0
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(NULL);
|
||||
ret = (FAR struct posix_timer_s *)
|
||||
sq_remfirst((FAR sq_queue_t *)&g_freetimers);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(NULL, flags);
|
||||
|
||||
/* Did we get one? */
|
||||
|
||||
|
@ -91,9 +92,9 @@ static FAR struct posix_timer_s *timer_allocate(void)
|
|||
|
||||
/* And add it to the end of the list of allocated timers */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(NULL);
|
||||
sq_addlast((FAR sq_entry_t *)ret, (FAR sq_queue_t *)&g_alloctimers);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(NULL, flags);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <nuttx/irq.h>
|
||||
#include <nuttx/queue.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
#include "timer/timer.h"
|
||||
|
||||
|
@ -54,7 +55,7 @@ static inline void timer_free(struct posix_timer_s *timer)
|
|||
|
||||
/* Remove the timer from the allocated list */
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(NULL);
|
||||
sq_rem((FAR sq_entry_t *)timer, (FAR sq_queue_t *)&g_alloctimers);
|
||||
|
||||
/* Return it to the free list if it is one of the preallocated timers */
|
||||
|
@ -63,14 +64,14 @@ static inline void timer_free(struct posix_timer_s *timer)
|
|||
if ((timer->pt_flags & PT_FLAGS_PREALLOCATED) != 0)
|
||||
{
|
||||
sq_addlast((FAR sq_entry_t *)timer, (FAR sq_queue_t *)&g_freetimers);
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(NULL, flags);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Otherwise, return it to the heap */
|
||||
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(NULL, flags);
|
||||
kmm_free(timer);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue