LP worker: When queuing new work, don't signal any threads if they are all busy

This commit is contained in:
Heesub Shin 2016-11-06 07:56:38 -06:00 committed by Gregory Nutt
parent 796969f6b6
commit 3c2a00bc4b
2 changed files with 12 additions and 9 deletions

View File

@ -152,7 +152,7 @@ int work_queue(int qid, FAR struct work_s *work, worker_t worker,
#ifdef CONFIG_SCHED_HPWORK
if (qid == HPWORK)
{
/* Cancel high priority work */
/* Queue high priority work */
work_qqueue((FAR struct kwork_wqueue_s *)&g_hpwork, work, worker, arg, delay);
return work_signal(HPWORK);
@ -162,7 +162,7 @@ int work_queue(int qid, FAR struct work_s *work, worker_t worker,
#ifdef CONFIG_SCHED_LPWORK
if (qid == LPWORK)
{
/* Cancel low priority work */
/* Queue low priority work */
work_qqueue((FAR struct kwork_wqueue_s *)&g_lpwork, work, worker, arg, delay);
return work_signal(LPWORK);

View File

@ -85,12 +85,11 @@ int work_signal(int qid)
#ifdef CONFIG_SCHED_LPWORK
if (qid == LPWORK)
{
int wndx;
int i;
/* Find an IDLE worker thread */
for (wndx = 0, i = 0; i < CONFIG_SCHED_LPNTHREADS; i++)
for (i = 0; i < CONFIG_SCHED_LPNTHREADS; i++)
{
/* Is this worker thread busy? */
@ -98,16 +97,20 @@ int work_signal(int qid)
{
/* No.. select this thread */
wndx = i;
break;
}
}
/* Use the process ID of the IDLE worker thread (or the ID of worker
* thread 0 if all of the worker threads are busy).
*/
/* If all of the IDLE threads are busy, then just return successfully */
pid = g_lpwork.worker[wndx].pid;
if (i >= CONFIG_SCHED_LPNTHREADS)
{
return OK;
}
/* Otherwise, signal the first IDLE thread found */
pid = g_lpwork.worker[i].pid;
}
else
#endif