Add support for multiple low-priority worker threads

This commit is contained in:
Gregory Nutt
2014-10-10 16:24:50 -06:00
parent 438e3e1a90
commit 4a4b3ac537
14 changed files with 204 additions and 77 deletions
+1 -1
View File
@@ -92,7 +92,7 @@
*
****************************************************************************/
static int work_qcancel(FAR struct wqueue_s *wqueue, FAR struct work_s *work)
static int work_qcancel(FAR struct usr_wqueue_s *wqueue, FAR struct work_s *work)
{
int ret = -ENOENT;
+4 -3
View File
@@ -102,8 +102,9 @@
*
****************************************************************************/
static int work_qqueue(FAR struct wqueue_s *wqueue, FAR struct work_s *work,
worker_t worker, FAR void *arg, uint32_t delay)
static int work_qqueue(FAR struct usr_wqueue_s *wqueue,
FAR struct work_s *work, worker_t worker,
FAR void *arg, uint32_t delay)
{
DEBUGASSERT(work != NULL);
@@ -122,7 +123,7 @@ static int work_qqueue(FAR struct wqueue_s *wqueue, FAR struct work_s *work,
work->qtime = clock_systimer(); /* Time work queued */
dq_addlast((FAR dq_entry_t *)work, &wqueue->q);
kill(wqueue->pid[0], SIGWORK); /* Wake up the worker thread */
kill(wqueue->pid, SIGWORK); /* Wake up the worker thread */
work_unlock();
return OK;
+1 -1
View File
@@ -97,7 +97,7 @@ int work_signal(int qid)
{
/* Signal the worker thread */
ret = kill(g_usrwork.pid[0], SIGWORK);
ret = kill(g_usrwork.pid, SIGWORK);
if (ret < 0)
{
int errcode = errno;
+12 -12
View File
@@ -83,7 +83,7 @@
/* The state of the user mode work queue. */
struct wqueue_s g_usrwork;
struct usr_wqueue_s g_usrwork;
/* This semaphore supports exclusive access to the user-mode work queue */
@@ -118,7 +118,7 @@ extern pthread_mutex_t g_usrmutex;
*
****************************************************************************/
void work_process(FAR struct wqueue_s *wqueue)
void work_process(FAR struct usr_wqueue_s *wqueue)
{
volatile FAR struct work_s *work;
worker_t worker;
@@ -351,21 +351,21 @@ int work_usrstart(void)
/* Start a user-mode worker thread for use by applications. */
g_usrwork.pid[0] = task_create("uwork",
CONFIG_SCHED_USRWORKPRIORITY,
CONFIG_SCHED_USRWORKSTACKSIZE,
(main_t)work_usrthread,
(FAR char * const *)NULL);
g_usrwork.pid = task_create("uwork",
CONFIG_SCHED_USRWORKPRIORITY,
CONFIG_SCHED_USRWORKSTACKSIZE,
(main_t)work_usrthread,
(FAR char * const *)NULL);
DEBUGASSERT(g_usrwork.pid[0] > 0);
if (g_usrwork.pid[0] < 0)
DEBUGASSERT(g_usrwork.pid > 0);
if (g_usrwork.pid < 0)
{
int errcode = errno;
DEBUGASSERT(errcode > 0);
return -errcode;
}
return g_usrwork.pid[0];
return g_usrwork.pid;
}
#else
{
@@ -398,8 +398,8 @@ int work_usrstart(void)
(void)pthread_detach(usrwork);
g_usrwork.pid[0] = (pid_t)usrwork;
return g_usrwork.pid[0];
g_usrwork.pid = (pid_t)usrwork;
return g_usrwork.pid;
}
#endif
}
+10 -1
View File
@@ -57,6 +57,15 @@
* Public Type Definitions
****************************************************************************/
/* This structure defines the state of one user-modework queue. */
struct usr_wqueue_s
{
uint32_t delay; /* Delay between polling cycles (ticks) */
struct dq_queue_s q; /* The queue of pending work */
pid_t pid; /* The task ID of the worker thread(s) */
};
/****************************************************************************
* Public Data
****************************************************************************/
@@ -64,7 +73,7 @@
#if defined(CONFIG_SCHED_USRWORK) && !defined(__KERNEL__)
/* The state of the user mode work queue */
extern struct wqueue_s g_usrwork;
extern struct usr_wqueue_s g_usrwork;
/* This semaphore/mutex supports exclusive access to the user-mode work queue */