Skip to content

Commit

Permalink
wqueue: add interface work_queue_priority_wq and work_queue_priority
Browse files Browse the repository at this point in the history
reason:
These interfaces are used when we assign interrupt
handling of the same priority to the corresponding priority work queues.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
  • Loading branch information
hujun260 committed Aug 30, 2024
1 parent ce2ad51 commit 8ea713d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/nuttx/wqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,24 @@ int work_queue_wq(FAR struct kwork_wqueue_s *wqueue,
FAR struct work_s *work, worker_t worker,
FAR void *arg, clock_t delay);

/****************************************************************************
* Name: work_queue_pri
*
* Description: Get priority of the wqueue. We believe that all worker
* threads have the same priority.
*
* Input Parameters:
* wqueue - The work queue handle
*
* Returned Value:
* SCHED_PRIORITY_MIN ~ SCHED_PRIORITY_MAX on success,
* a negated errno value on failure.
*
****************************************************************************/

int work_queue_priority(int qid);
int work_queue_priority_wq(FAR struct kwork_wqueue_s *wqueue);

/****************************************************************************
* Name: work_cancel/work_cancel_wq
*
Expand Down
40 changes: 40 additions & 0 deletions sched/wqueue/kwork_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,46 @@ int work_queue_free(FAR struct kwork_wqueue_s *wqueue)
return OK;
}

/****************************************************************************
* Name: work_queue_priority_wq
*
* Description: Get priority of the wqueue. We believe that all worker
* threads have the same priority.
*
* Input Parameters:
* wqueue - The work queue handle
*
* Returned Value:
* SCHED_PRIORITY_MIN ~ SCHED_PRIORITY_MAX on success,
* a negated errno value on failure.
*
****************************************************************************/

int work_queue_priority_wq(FAR struct kwork_wqueue_s *wqueue)
{
FAR struct tcb_s *tcb;

if (wqueue == NULL)
{
return -EINVAL;
}

/* Find for the TCB associated with matching PID */

tcb = nxsched_get_tcb(wqueue->worker[0].pid);
if (!tcb)
{
return -ESRCH;
}

return tcb->sched_priority;
}

int work_queue_priority(int qid)
{
return work_queue_priority_wq(work_qid2wq(qid));
}

/****************************************************************************
* Name: work_start_highpri
*
Expand Down

0 comments on commit 8ea713d

Please sign in to comment.