mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Add support for delays of different durations in work queue processing
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
#include "wqueue/wqueue.h"
|
||||
|
||||
@@ -151,19 +152,20 @@ int work_hpstart(void)
|
||||
{
|
||||
/* Initialize work queue data structures */
|
||||
|
||||
g_hpwork.delay = CONFIG_SCHED_WORKPERIOD / USEC_PER_TICK;
|
||||
dq_init(&g_hpwork.q);
|
||||
|
||||
/* Start the high-priority, kernel mode worker thread */
|
||||
|
||||
svdbg("Starting high-priority kernel worker thread\n");
|
||||
|
||||
g_hpwork.pid = kernel_thread(HPWORKNAME, CONFIG_SCHED_WORKPRIORITY,
|
||||
CONFIG_SCHED_WORKSTACKSIZE,
|
||||
(main_t)work_hpthread,
|
||||
(FAR char * const *)NULL);
|
||||
g_hpwork.pid[0] = kernel_thread(HPWORKNAME, CONFIG_SCHED_WORKPRIORITY,
|
||||
CONFIG_SCHED_WORKSTACKSIZE,
|
||||
(main_t)work_hpthread,
|
||||
(FAR char * const *)NULL);
|
||||
|
||||
DEBUGASSERT(g_hpwork.pid > 0);
|
||||
if (g_hpwork.pid < 0)
|
||||
DEBUGASSERT(g_hpwork.pid[0] > 0);
|
||||
if (g_hpwork.pid[0] < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
DEBUGASSERT(errcode > 0);
|
||||
@@ -172,7 +174,7 @@ int work_hpstart(void)
|
||||
return -errcode;
|
||||
}
|
||||
|
||||
return g_hpwork.pid;
|
||||
return g_hpwork.pid[0];
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SCHED_WORKQUEUE && CONFIG_SCHED_HPWORK*/
|
||||
|
||||
@@ -91,7 +91,7 @@ void lpwork_boostpriority(uint8_t reqprio)
|
||||
* thread from the process ID.
|
||||
*/
|
||||
|
||||
wpid = g_lpwork.pid;
|
||||
wpid = g_lpwork.pid[0];
|
||||
wtcb = sched_gettcb(wpid);
|
||||
|
||||
/* Prevent context switches until we get the priorities right */
|
||||
@@ -214,7 +214,7 @@ void lpwork_restorepriority(uint8_t reqprio)
|
||||
* thread from the process ID.
|
||||
*/
|
||||
|
||||
wpid = g_lpwork.pid;
|
||||
wpid = g_lpwork.pid[0];
|
||||
wtcb = sched_gettcb(wpid);
|
||||
|
||||
/* Prevent context switches until we get the priorities right */
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/kthread.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
#include "wqueue/wqueue.h"
|
||||
|
||||
@@ -148,19 +149,20 @@ int work_lpstart(void)
|
||||
{
|
||||
/* Initialize work queue data structures */
|
||||
|
||||
g_lpwork.delay = CONFIG_SCHED_LPWORKPERIOD / USEC_PER_TICK;
|
||||
dq_init(&g_lpwork.q);
|
||||
|
||||
/* Start the low-priority, kernel mode worker thread(s) */
|
||||
|
||||
svdbg("Starting low-priority kernel worker thread\n");
|
||||
|
||||
g_lpwork.pid = kernel_thread(LPWORKNAME, CONFIG_SCHED_LPWORKPRIORITY,
|
||||
CONFIG_SCHED_LPWORKSTACKSIZE,
|
||||
(main_t)work_lpthread,
|
||||
(FAR char * const *)NULL);
|
||||
g_lpwork.pid[0] = kernel_thread(LPWORKNAME, CONFIG_SCHED_LPWORKPRIORITY,
|
||||
CONFIG_SCHED_LPWORKSTACKSIZE,
|
||||
(main_t)work_lpthread,
|
||||
(FAR char * const *)NULL);
|
||||
|
||||
DEBUGASSERT(g_lpwork.pid > 0);
|
||||
if (g_lpwork.pid < 0)
|
||||
DEBUGASSERT(g_lpwork.pid[0] > 0);
|
||||
if (g_lpwork.pid[0] < 0)
|
||||
{
|
||||
int errcode = errno;
|
||||
DEBUGASSERT(errcode > 0);
|
||||
@@ -169,7 +171,7 @@ int work_lpstart(void)
|
||||
return -errcode;
|
||||
}
|
||||
|
||||
return g_lpwork.pid;
|
||||
return g_lpwork.pid[0];
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SCHED_WORKQUEUE && CONFIG_SCHED_LPWORK */
|
||||
|
||||
@@ -97,14 +97,14 @@ int work_signal(int qid)
|
||||
#ifdef CONFIG_SCHED_HPWORK
|
||||
if (qid == HPWORK)
|
||||
{
|
||||
pid = g_hpwork.pid;
|
||||
pid = g_hpwork.pid[0];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef CONFIG_SCHED_LPWORK
|
||||
if (qid == LPWORK)
|
||||
{
|
||||
pid = g_lpwork.pid;
|
||||
pid = g_lpwork.pid[0];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user