diff --git a/include/nuttx/wqueue.h b/include/nuttx/wqueue.h index b20d5a1ac4..0b495ae4a3 100644 --- a/include/nuttx/wqueue.h +++ b/include/nuttx/wqueue.h @@ -245,7 +245,7 @@ /* Kernel mode */ # define HPWORK 0 /* High priority, kernel-mode work queue */ -# ifdef CONFIG_SCHED_LPWORK +# if defined(CONFIG_SCHED_LPWORK) && defined(CONFIG_SCHED_HPWORK) # define LPWORK (HPWORK+1) /* Low priority, kernel-mode work queue */ # else # define LPWORK HPWORK /* Redirect low-priority references */ diff --git a/mm/iob/Kconfig b/mm/iob/Kconfig index d39c6c4dad..aad4c6c401 100644 --- a/mm/iob/Kconfig +++ b/mm/iob/Kconfig @@ -62,7 +62,7 @@ config IOB_THROTTLE config IOB_NOTIFIER bool "Support IOB notifications" default n - depends on SCHED_HPWORK + depends on SCHED_WORKQUEUE select WQUEUE_NOTIFIER ---help--- Enable building of IOB notifier logic that will execute a worker diff --git a/net/netdev/Kconfig b/net/netdev/Kconfig index 8714627326..2b3f905026 100644 --- a/net/netdev/Kconfig +++ b/net/netdev/Kconfig @@ -39,7 +39,7 @@ config NETDEV_IFINDEX config NETDOWN_NOTIFIER bool "Support network down notifications" default n - depends on SCHED_LPWORK + depends on SCHED_WORKQUEUE select WQUEUE_NOTIFIER ---help--- Enable building of logic that will execute on the low priority work diff --git a/net/tcp/Kconfig b/net/tcp/Kconfig index 88c6de20cf..3d5789e4bf 100644 --- a/net/tcp/Kconfig +++ b/net/tcp/Kconfig @@ -50,7 +50,7 @@ config NET_MAX_LISTENPORTS config TCP_NOTIFIER bool "Support TCP notifications" default n - depends on SCHED_LPWORK + depends on SCHED_WORKQUEUE select WQUEUE_NOTIFIER ---help--- Enable building of TCP notifier logic that will execute a worker diff --git a/net/udp/Kconfig b/net/udp/Kconfig index 717a89d9c2..d6bf806988 100644 --- a/net/udp/Kconfig +++ b/net/udp/Kconfig @@ -60,7 +60,7 @@ config NET_UDP_READAHEAD config UDP_READAHEAD_NOTIFIER bool "Support UDP read-ahead notifications" default n - depends on NET_UDP_READAHEAD && SCHED_HPWORK + depends on NET_UDP_READAHEAD && SCHED_WORKQUEUE select WQUEUE_NOTIFIER ---help--- Enable building of UDP read-ahead notifier logic that will execute a diff --git a/sched/Kconfig b/sched/Kconfig index 36e4701ef1..3ec9944bd5 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -1469,6 +1469,16 @@ config SCHED_WORKQUEUE Create dedicated "worker" threads to handle delayed or asynchronous processing. +config WQUEUE_NOTIFIER + bool "Generic work notifier" + default n + depends on SCHED_WORKQUEUE + ---help--- + Enable building of work queue notifier logic that will execute a + worker function an event occurs. This is is a general purpose + notifier, but was developed specifically to support poll() logic + where the poll must wait for an resources to become available. + config SCHED_HPWORK bool "High priority (kernel) worker thread" default n @@ -1534,15 +1544,6 @@ config SCHED_HPWORKSTACKSIZE ---help--- The stack size allocated for the worker thread. Default: 2K. -config WQUEUE_NOTIFIER - bool "Generic work notifier" - default n - ---help--- - Enable building of work queue notifier logic that will execute a - worker function an event occurs. This is is a general purpose - notifier, but was developed specifically to support poll() logic - where the poll must wait for an resources to become available. - endif # SCHED_HPWORK config SCHED_LPWORK diff --git a/sched/wqueue/kwork_notifier.c b/sched/wqueue/kwork_notifier.c index 83a2b28f5a..5ae5badcb3 100644 --- a/sched/wqueue/kwork_notifier.c +++ b/sched/wqueue/kwork_notifier.c @@ -211,7 +211,7 @@ int work_notifier_setup(FAR struct work_notifier_s *info) */ dq_addlast((FAR dq_entry_t *)notifier, &g_notifier_pending); - ret = work_notifier_key(); + ret = notifier->key; } (void)nxsem_post(&g_notifier_sem); @@ -310,11 +310,12 @@ void work_notifier_signal(enum work_evtype_e evtype, /* Get exclusive access to the notifier data structure */ - ret = nxsem_wait(&g_notifier_sem); - while (ret < 0) + do { + ret = nxsem_wait(&g_notifier_sem); DEBUGASSERT(ret == -EINTR || ret == -ECANCELED); } + while (ret < 0); /* Don't let any newly started threads block this thread until all of * the notifications and been sent. @@ -325,8 +326,6 @@ void work_notifier_signal(enum work_evtype_e evtype, /* Process the notification at the head of the pending list until the * pending list is empty */ - /* Find the entry matching this key in the g_notifier_pending list. */ - for (entry = dq_peek(&g_notifier_pending); entry != NULL; entry = next)