You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/10/21 03:00:13 UTC
[nuttx] branch master updated: Replace enter_critical_section with spin_irqsave
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 51eaa59cc0 Replace enter_critical_section with spin_irqsave
51eaa59cc0 is described below
commit 51eaa59cc0ed9732eb69ac99c3e325e811a027f0
Author: TaiJuWu <tj...@gmail.com>
AuthorDate: Fri Oct 20 17:51:18 2023 +0800
Replace enter_critical_section with spin_irqsave
Base on discusion: https://github.com/apache/nuttx/issues/10981
Signed-off-by: TaiJuWu <tj...@gmail.com>
---
mm/mm_heap/mm_malloc.c | 4 ++--
sched/timer/timer_create.c | 9 +++++----
sched/timer/timer_release.c | 7 ++++---
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c
index 6d39ef2b32..c8c12a974d 100644
--- a/mm/mm_heap/mm_malloc.c
+++ b/mm/mm_heap/mm_malloc.c
@@ -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 */
diff --git a/sched/timer/timer_create.c b/sched/timer/timer_create.c
index e9bd4dcf4b..315d771d2b 100644
--- a/sched/timer/timer_create.c
+++ b/sched/timer/timer_create.c
@@ -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;
diff --git a/sched/timer/timer_release.c b/sched/timer/timer_release.c
index bfd85b6564..0b922f0f87 100644
--- a/sched/timer/timer_release.c
+++ b/sched/timer/timer_release.c
@@ -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);
}
}