mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
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:
@@ -41,6 +41,7 @@
|
|||||||
#define OSINIT_MM_READY() (g_nx_initstate >= OSINIT_MEMORY)
|
#define OSINIT_MM_READY() (g_nx_initstate >= OSINIT_MEMORY)
|
||||||
#define OSINIT_HW_READY() (g_nx_initstate >= OSINIT_HARDWARE)
|
#define OSINIT_HW_READY() (g_nx_initstate >= OSINIT_HARDWARE)
|
||||||
#define OSINIT_OS_READY() (g_nx_initstate >= OSINIT_OSREADY)
|
#define OSINIT_OS_READY() (g_nx_initstate >= OSINIT_OSREADY)
|
||||||
|
#define OSINIT_IDLELOOP() (g_nx_initstate >= OSINIT_IDLELOOP)
|
||||||
#define OSINIT_OS_INITIALIZING() (g_nx_initstate < OSINIT_OSREADY)
|
#define OSINIT_OS_INITIALIZING() (g_nx_initstate < OSINIT_OSREADY)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -65,8 +66,9 @@ enum nx_initstate_e
|
|||||||
* to support the hardware are also available but
|
* to support the hardware are also available but
|
||||||
* the OS has not yet completed its full
|
* the OS has not yet completed its full
|
||||||
* initialization. */
|
* initialization. */
|
||||||
OSINIT_OSREADY = 5 /* The OS is fully initialized and multi-tasking is
|
OSINIT_OSREADY = 5, /* The OS is fully initialized and multi-tasking is
|
||||||
* active. */
|
* active. */
|
||||||
|
OSINIT_IDLELOOP = 6 /* The OS enter idle loop */
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -776,6 +776,10 @@ void nx_start(void)
|
|||||||
|
|
||||||
DEBUGVERIFY(nx_bringup());
|
DEBUGVERIFY(nx_bringup());
|
||||||
|
|
||||||
|
/* Enter to idleloop */
|
||||||
|
|
||||||
|
g_nx_initstate = OSINIT_IDLELOOP;
|
||||||
|
|
||||||
/* Let other threads have access to the memory manager */
|
/* Let other threads have access to the memory manager */
|
||||||
|
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/init.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
|
||||||
@@ -69,9 +70,10 @@ int nxsem_trywait(FAR sem_t *sem)
|
|||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int ret;
|
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(sem != NULL && up_interrupt_context() == false);
|
||||||
|
DEBUGASSERT(OSINIT_IDLELOOP() && !sched_idletask());
|
||||||
|
|
||||||
if (sem != NULL)
|
if (sem != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <nuttx/init.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/cancelpt.h>
|
#include <nuttx/cancelpt.h>
|
||||||
@@ -73,9 +74,10 @@ int nxsem_wait(FAR sem_t *sem)
|
|||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
int ret = -EINVAL;
|
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(sem != NULL && up_interrupt_context() == false);
|
||||||
|
DEBUGASSERT(OSINIT_IDLELOOP() && !sched_idletask());
|
||||||
|
|
||||||
/* The following operations must be performed with interrupts
|
/* The following operations must be performed with interrupts
|
||||||
* disabled because nxsem_post() may be called from an interrupt
|
* disabled because nxsem_post() may be called from an interrupt
|
||||||
|
|||||||
Reference in New Issue
Block a user