[concurrency-interest] Fixed thread pool problem?

Allan Kielstra kielstra at ca.ibm.com
Fri Aug 31 17:46:52 EDT 2007

Here's what happens on my 8-way Power5 running AIX when I use the second 
infinite loop (the one marked  // while (list != null) {} // only produces 
100% CPU on a dual processor system [B])

list.size() is 0 for all Scanners except Scanner 1.  Therefore, all 
Scanners except Scanner 1 return some value pretty quickly.  Scanner 1 
waits forever.  scheduleRepeatChecks retrieves a result for Scanner 0 and 
then freezes waiting for Scanner 1.  Since scheduelRepeatChecks never 
returns, the step method never returns either.  So the whole system is 
waiting for Scanner 1 to finish and no new work is being generated. 
(Because Scanner 1 is the only thing executing a busy wait;  everything 
else is suspended waiting for something to do.)

Here's what happens when I use the first infinite loop (the one marked // 
while (list != null) {} // produces 2x100% CPU on a dual processor system 
[A] )

All Scanners go into an infinite loop.  Pretty soon the system divides the 
busy work among all the processors as follows:
cpu 2 is creating/submitting Futures
cpu 2 is checking Future 0
scanner 0initially running on cpu4
scanner 4initially running on cpu1
scanner 1initially running on cpu0
scanner 6initially running on cpu1
scanner 7initially running on cpu0
scanner 2initially running on cpu1
scanner 3initially running on cpu0
scanner 5initially running on cpu3
scanner 1migrated from 0 to 2
scanner 7migrated from 0 to 6
scanner 2migrated from 1 to 5
scanner 4migrated from 1 to 7
scanner 2migrated from 5 to 0
scanner 0migrated from 4 to 5
scanner 0migrated from 5 to 4
scanner 3migrated from 0 to 5
Now all CPUs are running a busy loop instead of code that is waiting in a 
suspended state.  Hence all CPUs appear to be busy.

Going back to the first case, AIX does gamely try:
scanner 1initially running on cpu1
scanner 1migrated from 1 to 2

but to no avail.  Only 1 CPU appears to be really busy.

Allan Kielstra
IBM Canada Lab
Phone: +1 (905) 413-3558 T/L 969-3558
kielstra at ca.ibm.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20070831/bec60bde/attachment.html 

More information about the Concurrency-interest mailing list