From 4b18b8d1e3e24a60d5ae452df7cfafe4545cd880 Mon Sep 17 00:00:00 2001 From: linfei_chen Date: Tue, 22 Mar 2016 08:15:49 -0600 Subject: [PATCH] LP Work Queue: Fix test to find and idle worker thread. --- ChangeLog | 2 ++ sched/wqueue/kwork_signal.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3bcb07ffca..6b9b48b4fd 100755 --- a/ChangeLog +++ b/ChangeLog @@ -11577,4 +11577,6 @@ * net/tcp/tcp_timer.c: Fix some logic when there are multiple network interfaces. In this case, TCP timeout events can really only being processed when the poll from the correct device is received (2016-03-20). + * sched/wqueue/kwork_signal.c: Fix logic to find an IDLE worker thread; + the test for busy was backward. From Linfei Chen (2016-03-22). diff --git a/sched/wqueue/kwork_signal.c b/sched/wqueue/kwork_signal.c index a4d94dbef9..9359fb2e2a 100644 --- a/sched/wqueue/kwork_signal.c +++ b/sched/wqueue/kwork_signal.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/wqueue/work_signal.c * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -92,15 +92,19 @@ int work_signal(int qid) for (wndx = 0, i = 0; i < CONFIG_SCHED_LPNTHREADS; i++) { - if (g_lpwork.worker[i].busy) + /* Is this worker thread busy? */ + + if (!g_lpwork.worker[i].busy) { + /* No.. select this thread */ + wndx = i; break; } } - /* Use the process ID of the IDLE thread (or thread 0 is the are all - * busy) + /* Use the process ID of the IDLE worker thread (or the ID of worker + * thread 0 if all of the worker threads are busy). */ pid = g_lpwork.worker[wndx].pid;