wqueue: update wqueue to support using wqueue before wqueue start

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd 2021-12-01 23:40:16 +08:00 committed by Xiang Xiao
parent 5c5bd7161c
commit 166a9210ca
2 changed files with 27 additions and 5 deletions

View File

@ -36,6 +36,21 @@
* Pre-processor Definitions
****************************************************************************/
/* Initializers */
#ifdef CONFIG_PRIORITY_INHERITANCE
# if CONFIG_SEM_PREALLOCHOLDERS > 0
# define NXSEM_INITIALIZER(c, f) \
{(c), (f), NULL} /* semcount, flags, hhead */
# else
# define NXSEM_INITIALIZER(c, f) \
{(c), (f), {{NULL, 0}, {NULL, 0}}} /* semcount, flags, holder[2] */
# endif
#else /* CONFIG_PRIORITY_INHERITANCE */
# define NXSEM_INITIALIZER(c, f) \
{(c)} /* semcount, flags */
#endif /* CONFIG_PRIORITY_INHERITANCE */
/* Most internal nxsem_* interfaces are not available in the user space in
* PROTECTED and KERNEL builds. In that context, the application semaphore
* interfaces must be used. The differences between the two sets of

View File

@ -73,13 +73,23 @@
#if defined(CONFIG_SCHED_HPWORK)
/* The state of the kernel mode, high priority work queue(s). */
struct hp_wqueue_s g_hpwork;
struct hp_wqueue_s g_hpwork =
{
{},
NXSEM_INITIALIZER(0, SEM_PRIO_NONE),
};
#endif /* CONFIG_SCHED_HPWORK */
#if defined(CONFIG_SCHED_LPWORK)
/* The state of the kernel mode, low priority work queue(s). */
struct lp_wqueue_s g_lpwork;
struct lp_wqueue_s g_lpwork =
{
{},
NXSEM_INITIALIZER(0, SEM_PRIO_NONE),
};
#endif /* CONFIG_SCHED_LPWORK */
/****************************************************************************
@ -203,9 +213,6 @@ static int work_thread_create(FAR const char *name, int priority,
argv[0] = args;
argv[1] = NULL;
nxsem_init(&wqueue->sem, 0, 0);
nxsem_set_protocol(&wqueue->sem, SEM_PRIO_NONE);
/* Don't permit any of the threads to run until we have fully initialized
* g_hpwork and g_lpwork.
*/