You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/04/19 13:51:29 UTC
[incubator-nuttx] 01/02: arch/sim: All cpu core need conform to
CONFIG_SIM_WALLTIME behaviour
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 2a7029dd529d2390eecb44f2b17d71bb536655c4
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sat Apr 18 01:04:08 2020 +0800
arch/sim: All cpu core need conform to CONFIG_SIM_WALLTIME behaviour
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
arch/sim/src/Makefile | 4 ++++
arch/sim/src/sim/up_simsmp.c | 10 ++++++++++
2 files changed, 14 insertions(+)
diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile
index f9456ef..6f39c90 100644
--- a/arch/sim/src/Makefile
+++ b/arch/sim/src/Makefile
@@ -94,6 +94,10 @@ ifeq ($(CONFIG_SMP),y)
CSRCS += up_smpsignal.c up_cpuidlestack.c
REQUIREDOBJS += up_smpsignal$(OBJEXT)
HOSTCFLAGS += -DCONFIG_SMP=1 -DCONFIG_SMP_NCPUS=$(CONFIG_SMP_NCPUS)
+ HOSTCFLAGS += -DCONFIG_USEC_PER_TICK=$(CONFIG_USEC_PER_TICK)
+ifeq ($(CONFIG_SIM_WALLTIME),y)
+ HOSTCFLAGS += -DCONFIG_SIM_WALLTIME=1
+endif
HOSTSRCS += up_simsmp.c
STDLIBS += -lpthread
endif
diff --git a/arch/sim/src/sim/up_simsmp.c b/arch/sim/src/sim/up_simsmp.c
index aa06126..a775ad1 100644
--- a/arch/sim/src/sim/up_simsmp.c
+++ b/arch/sim/src/sim/up_simsmp.c
@@ -98,6 +98,7 @@ volatile spinlock_t g_cpu_paused[CONFIG_SMP_NCPUS];
void nx_start(void);
void up_cpu_started(void);
int up_cpu_paused(int cpu);
+void host_sleepuntil(uint64_t nsec);
/****************************************************************************
* Private Functions
@@ -162,9 +163,18 @@ static void *sim_idle_trampoline(void *arg)
for (; ; )
{
+#ifdef CONFIG_SIM_WALLTIME
+ uint64_t now = 0;
+
+ /* Wait a bit so that the timing is close to the correct rate. */
+
+ now += 1000 * CONFIG_USEC_PER_TICK;
+ host_sleepuntil(now);
+#else
/* Give other pthreads/CPUs a shot */
pthread_yield();
+#endif
}
return NULL;