summaryrefslogtreecommitdiff
path: root/nuttx/sched/work_queue.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-04 00:54:09 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-04 00:54:09 +0000
commitd8aa30d561322f24cf0eb67f27f41ad9ab52474e (patch)
tree7bfc2aaf9a03320f24991b54a67a1db24e05f100 /nuttx/sched/work_queue.c
parented14f7102218c784f1f22649485de262f34a6507 (diff)
downloadpx4-nuttx-d8aa30d561322f24cf0eb67f27f41ad9ab52474e.tar.gz
px4-nuttx-d8aa30d561322f24cf0eb67f27f41ad9ab52474e.tar.bz2
px4-nuttx-d8aa30d561322f24cf0eb67f27f41ad9ab52474e.zip
Add support for multiple work queues
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5081 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/work_queue.c')
-rw-r--r--nuttx/sched/work_queue.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/nuttx/sched/work_queue.c b/nuttx/sched/work_queue.c
index beeac168d..075f08a4d 100644
--- a/nuttx/sched/work_queue.c
+++ b/nuttx/sched/work_queue.c
@@ -76,6 +76,7 @@
/****************************************************************************
* Public Functions
****************************************************************************/
+
/****************************************************************************
* Name: work_queue
*
@@ -91,6 +92,7 @@
* and remove it from the work queue.
*
* Input parameters:
+ * qid - The work queue ID (index)
* work - The work structure to queue
* worker - The worker callback to be invoked. The callback will invoked
* on the worker thread of execution.
@@ -104,11 +106,13 @@
*
****************************************************************************/
-int work_queue(struct work_s *work, worker_t worker, FAR void *arg, uint32_t delay)
+int work_queue(int qid, FAR struct work_s *work, worker_t worker,
+ FAR void *arg, uint32_t delay)
{
+ FAR struct wqueue_s *wqueue = &g_work[qid];
irqstate_t flags;
- DEBUGASSERT(work != NULL);
+ DEBUGASSERT(work != NULL && (unsigned)qid < NWORKERS);
/* First, initialize the work structure */
@@ -123,8 +127,10 @@ int work_queue(struct work_s *work, worker_t worker, FAR void *arg, uint32_t del
flags = irqsave();
work->qtime = clock_systimer(); /* Time work queued */
- dq_addlast((FAR dq_entry_t *)work, &g_work);
- work_signal(); /* Wake up the worker thread */
+
+ dq_addlast((FAR dq_entry_t *)work, &wqueue->q);
+ kill(wqueue->pid, SIGWORK); /* Wake up the worker thread */
+
irqrestore(flags);
return OK;
}