mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Work queues: Logic that sets the queued indication and the logic that does the actual queuing must be atomic
This commit is contained in:
@@ -109,8 +109,10 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue,
|
||||
{
|
||||
/* A little test of the integrity of the work queue */
|
||||
|
||||
DEBUGASSERT(work->dq.flink || (FAR dq_entry_t *)work == wqueue->q.tail);
|
||||
DEBUGASSERT(work->dq.blink || (FAR dq_entry_t *)work == wqueue->q.head);
|
||||
DEBUGASSERT(work->dq.flink != NULL ||
|
||||
(FAR dq_entry_t *)work == wqueue->q.tail);
|
||||
DEBUGASSERT(work->dq.blink != NULL ||
|
||||
(FAR dq_entry_t *)work == wqueue->q.head);
|
||||
|
||||
/* Remove the entry from the work queue and make sure that it is
|
||||
* mark as available (i.e., the worker field is nullified).
|
||||
|
||||
+10
-10
@@ -107,20 +107,20 @@ static void work_qqueue(FAR struct kwork_wqueue_s *wqueue,
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
DEBUGASSERT(work != NULL);
|
||||
DEBUGASSERT(work != NULL && worker != NULL);
|
||||
|
||||
/* First, initialize the work structure */
|
||||
|
||||
work->worker = worker; /* Work callback */
|
||||
work->arg = arg; /* Callback argument */
|
||||
work->delay = delay; /* Delay until work performed */
|
||||
|
||||
/* Now, time-tag that entry and put it in the work queue. This must be
|
||||
* done with interrupts disabled. This permits this function to be called
|
||||
* from with task logic or interrupt handlers.
|
||||
/* First, initialize the work structure. This must be done with interrupts
|
||||
* disabled. This permits this function to be called from with task logic
|
||||
* or interrupt handlers.
|
||||
*/
|
||||
|
||||
flags = irqsave();
|
||||
work->worker = worker; /* Work callback. non-NULL means queued */
|
||||
work->arg = arg; /* Callback argument */
|
||||
work->delay = delay; /* Delay until work performed */
|
||||
|
||||
/* Now, time-tag that entry and put it in the work queue */
|
||||
|
||||
work->qtime = clock_systimer(); /* Time work queued */
|
||||
|
||||
dq_addlast((FAR dq_entry_t *)work, &wqueue->q);
|
||||
|
||||
Reference in New Issue
Block a user