Skip to content

Commit b1884d2

Browse files
hujun260xiaoxiang781216
authored andcommitted
wqueue: add interface work_queue_priority_wq and work_queue_priority
reason: These interfaces are used when we assign interrupt handling of the same priority to the corresponding priority work queues. Signed-off-by: hujun5 <[email protected]>
1 parent 79199e2 commit b1884d2

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

include/nuttx/wqueue.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,24 @@ int work_queue_wq(FAR struct kwork_wqueue_s *wqueue,
413413
FAR struct work_s *work, worker_t worker,
414414
FAR void *arg, clock_t delay);
415415

416+
/****************************************************************************
417+
* Name: work_queue_pri
418+
*
419+
* Description: Get priority of the wqueue. We believe that all worker
420+
* threads have the same priority.
421+
*
422+
* Input Parameters:
423+
* wqueue - The work queue handle
424+
*
425+
* Returned Value:
426+
* SCHED_PRIORITY_MIN ~ SCHED_PRIORITY_MAX on success,
427+
* a negated errno value on failure.
428+
*
429+
****************************************************************************/
430+
431+
int work_queue_priority(int qid);
432+
int work_queue_priority_wq(FAR struct kwork_wqueue_s *wqueue);
433+
416434
/****************************************************************************
417435
* Name: work_cancel/work_cancel_wq
418436
*

sched/wqueue/kwork_thread.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,46 @@ int work_queue_free(FAR struct kwork_wqueue_s *wqueue)
393393
return OK;
394394
}
395395

396+
/****************************************************************************
397+
* Name: work_queue_priority_wq
398+
*
399+
* Description: Get priority of the wqueue. We believe that all worker
400+
* threads have the same priority.
401+
*
402+
* Input Parameters:
403+
* wqueue - The work queue handle
404+
*
405+
* Returned Value:
406+
* SCHED_PRIORITY_MIN ~ SCHED_PRIORITY_MAX on success,
407+
* a negated errno value on failure.
408+
*
409+
****************************************************************************/
410+
411+
int work_queue_priority_wq(FAR struct kwork_wqueue_s *wqueue)
412+
{
413+
FAR struct tcb_s *tcb;
414+
415+
if (wqueue == NULL)
416+
{
417+
return -EINVAL;
418+
}
419+
420+
/* Find for the TCB associated with matching PID */
421+
422+
tcb = nxsched_get_tcb(wqueue->worker[0].pid);
423+
if (!tcb)
424+
{
425+
return -ESRCH;
426+
}
427+
428+
return tcb->sched_priority;
429+
}
430+
431+
int work_queue_priority(int qid)
432+
{
433+
return work_queue_priority_wq(work_qid2wq(qid));
434+
}
435+
396436
/****************************************************************************
397437
* Name: work_start_highpri
398438
*

0 commit comments

Comments
 (0)