From 7062ca2c0379715c887d69d3c36c4033b29c753a Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Thu, 15 Feb 2018 14:18:25 +0000 Subject: [PATCH] Merged in masayuki2009/nuttx.nuttx/lc823450_smp_test (pull request #601) lc823450 smp test * sched/clock: Replace critical section APIs with spin lock APIs in clock_gettime.c This change will improve performance for SMP systems but nothing changes for non-SMP systems. (Pls see include/nuttx/irq.h) Signed-off-by: Masayuki Ishikawa * sched/sched: Remove unnecessary DEBUGASSERT in sched_removereadytorun.c In SMP mode, rtrtcb is not always at the g_readytorun.head. This change removes DEBUGASSERT() to avoid this condition. Signed-off-by: Masayuki Ishikawa Approved-by: Gregory Nutt --- sched/clock/clock_gettime.c | 8 ++++---- sched/sched/sched_removereadytorun.c | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sched/clock/clock_gettime.c b/sched/clock/clock_gettime.c index 731c6a2ae3..d3f1cd34a7 100644 --- a/sched/clock/clock_gettime.c +++ b/sched/clock/clock_gettime.c @@ -110,12 +110,12 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) * CLOCK_MONOTONIC be introduced additional increases to systime. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(); tp->tv_sec += (uint32_t)g_monotonic_basetime.tv_sec; tp->tv_nsec += (uint32_t)g_monotonic_basetime.tv_nsec; - leave_critical_section(flags); + spin_unlock_irqrestore(flags); /* Handle carry to seconds. */ @@ -163,12 +163,12 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) * was last set, this gives us the current time. */ - flags = enter_critical_section(); + flags = spin_lock_irqsave(); ts.tv_sec += (uint32_t)g_basetime.tv_sec; ts.tv_nsec += (uint32_t)g_basetime.tv_nsec; - leave_critical_section(flags); + spin_unlock_irqrestore(flags); /* Handle carry to seconds. */ diff --git a/sched/sched/sched_removereadytorun.c b/sched/sched/sched_removereadytorun.c index da4c24a352..aab359aa7d 100644 --- a/sched/sched/sched_removereadytorun.c +++ b/sched/sched/sched_removereadytorun.c @@ -238,8 +238,6 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb) tmptcb = (FAR struct tcb_s *) dq_remfirst((FAR dq_queue_t *)&g_readytorun); - DEBUGASSERT(tmptcb == rtrtcb); - dq_addfirst((FAR dq_entry_t *)tmptcb, tasklist); tmptcb->cpu = cpu;