os init_state: add new state OSINIT_IDLELOOP

This is for distinguish we are in init idle or idle loop.
Use for assertion for sem_trywait & sem_wait

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd
2022-02-21 18:14:10 +08:00
committed by Masayuki Ishikawa
parent 1dada85b52
commit 61a0453e6e
4 changed files with 13 additions and 3 deletions
+3 -1
View File
@@ -29,6 +29,7 @@
#include <assert.h>
#include <errno.h>
#include <nuttx/init.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
@@ -69,9 +70,10 @@ int nxsem_trywait(FAR sem_t *sem)
irqstate_t flags;
int ret;
/* This API should not be called from interrupt handlers */
/* This API should not be called from interrupt handlers & idleloop */
DEBUGASSERT(sem != NULL && up_interrupt_context() == false);
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask());
if (sem != NULL)
{
+3 -1
View File
@@ -28,6 +28,7 @@
#include <errno.h>
#include <assert.h>
#include <nuttx/init.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/cancelpt.h>
@@ -73,9 +74,10 @@ int nxsem_wait(FAR sem_t *sem)
irqstate_t flags;
int ret = -EINVAL;
/* This API should not be called from interrupt handlers */
/* This API should not be called from interrupt handlers & idleloop */
DEBUGASSERT(sem != NULL && up_interrupt_context() == false);
DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask());
/* The following operations must be performed with interrupts
* disabled because nxsem_post() may be called from an interrupt