From 3f7f58de9dc8912f382c063d0e67841ebb624838 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 12 Feb 2016 17:13:38 -0600 Subject: [PATCH] SMP: Fix some debug assertion problems when DEBUG is enabled; Partial fix for one bring-up issue --- arch | 2 +- sched/init/os_smpstart.c | 22 +++++++++++++--------- sched/semaphore/spinlock.c | 6 +++--- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/arch b/arch index a6ad88a85c..4abb852339 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit a6ad88a85c9e4c6ab633fb53f53603539206a57c +Subproject commit 4abb8523390cecded97fe325448213983e47aedf diff --git a/sched/init/os_smpstart.c b/sched/init/os_smpstart.c index 63164845a3..53a451f1cc 100644 --- a/sched/init/os_smpstart.c +++ b/sched/init/os_smpstart.c @@ -94,9 +94,21 @@ static const char g_idlename[] = "CPUn Idle" int os_idletask(int argc, FAR char *argv[]) { +#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 + /* Finish TCB initialization */ + + FAR struct task_tcb_s *rtcb = (FAR struct task_tcb_s *)this_task(); + + /* Create stdout, stderr, stdin on the IDLE task. These will be + * inherited by all of the threads created by the IDLE task. + */ + + DEBUGVERIFY(group_setupidlefiles(rtcb)); +#endif + /* Enter the IDLE loop */ - sdbg("CPU%d: Beginning Idle Loop\n"); + sdbg("CPU%d: Beginning Idle Loop\n", this_cpu()); for (; ; ) { /* Perform garbage collection (if it is not being done by the worker @@ -210,14 +222,6 @@ static FAR void *os_idletcb_setup(int cpu, main_t idletask, pid_t pid) DEBUGVERIFY(group_allocate(itcb, itcb->cmn.flags)); #endif -#if CONFIG_NFILE_DESCRIPTORS > 0 || CONFIG_NSOCKET_DESCRIPTORS > 0 - /* Create stdout, stderr, stdin on the IDLE task. These will be - * inherited by all of the threads created by the IDLE task. - */ - - DEBUGVERIFY(group_setupidlefiles(itcb)); -#endif - #ifdef HAVE_TASK_GROUP /* Complete initialization of the IDLE group. Suppress retention * of child status in the IDLE group. diff --git a/sched/semaphore/spinlock.c b/sched/semaphore/spinlock.c index a31df567d8..b5396273a8 100644 --- a/sched/semaphore/spinlock.c +++ b/sched/semaphore/spinlock.c @@ -251,7 +251,7 @@ void spin_unlockr(FAR struct spinlock_s *lock) * CPU and avoids such complexities. */ - DEBUGASSERT(lock != NULL && lock->sp-lock = SP_LOCKED && + DEBUGASSERT(lock != NULL && lock->sp_lock == SP_LOCKED && lock->sp_cpu == this_cpu() && lock->sp_count > 0); /* Do we already hold the lock? */ @@ -260,7 +260,7 @@ void spin_unlockr(FAR struct spinlock_s *lock) #else /* The alternative is to allow the lock to be released from any CPU */ - DEBUGASSERT(lock != NULL && lock->sp-lock = SP_LOCKED && + DEBUGASSERT(lock != NULL && lock->sp_lock == SP_LOCKED && lock->sp_count > 0); #endif @@ -286,7 +286,7 @@ void spin_unlockr(FAR struct spinlock_s *lock) #else /* CONFIG_SMP */ /* Just mark the spinlock unlocked */ - DEBUGASSERT(lock != NULL && lock->sp-lock = SP_LOCKED); + DEBUGASSERT(lock != NULL && lock->sp_lock == SP_LOCKED); lock->sp_lock = SP_UNLOCKED; #endif /* CONFIG_SMP */