Go to file
Thiago Macieira c8849dd8d5 Use waitid with WNOWAIT in forkfd
The previous implementation required one syscall per child we're waiting
on to see which one exited. That means the algorithm was O(n).

This implementation uses WNOWAIT to find out which child exited and then
goes straight to that one. So it's O(1) on the number of children, but
runs 2 * number_of_children_that_exited + 1 syscalls, assuming there are
no race conditions with other threads. If there are or if a child not
started by forkfd exits, we'll still iterate over each child we're
managing to see which one exited.

It modifies the existing code so that it will do a waitid() with WNOWAIT
to check on the status of the child: if the child has exited, we'll try
to lock the entry so only one thread will do the final wait(). In the
case we read the PID, then the child exited, was reaped by another
thread, the PID got recycled and that child exited again, we'll fail to
lock the ProcessInfo entry so no harm comes. If by an absurd coincidence
this other child was started by forkfd() and its ProcessInfo is exactly
the one we are looking at, then we'll succeed in locking but that's a
benign race: we'll do what the other thread was trying to do and the
other thread will give up.

Future improvements to the algorithm are discussed in the Gerrit change.

Change-Id: Ie74836dbc388cd9b3fa375a41a8d944602a32df1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2015-01-23 19:12:53 +01:00
bin Use the new warning enabling/disabling macros in qtbase 2014-12-03 18:09:17 +01:00
config.tests Add a configure-time check for an IPC support 2015-01-09 10:58:42 +01:00
dist Merge remote-tracking branch 'origin/5.4.0' into 5.4 2014-12-05 11:53:33 +01:00
doc Merge remote-tracking branch 'origin/5.4' into dev 2015-01-21 11:10:14 +01:00
examples D-Bus tray icon: ensure that the image is square before sending 2015-01-23 05:34:11 +01:00
lib Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
mkspecs Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev 2015-01-21 11:14:34 +01:00
qmake Merge remote-tracking branch 'origin/5.4' into dev 2015-01-21 11:10:14 +01:00
src Use waitid with WNOWAIT in forkfd 2015-01-23 19:12:53 +01:00
tests Use waitid with WNOWAIT in forkfd 2015-01-23 19:12:53 +01:00
tools Merge remote-tracking branch 'origin/5.4' into dev 2015-01-21 11:10:14 +01:00
util QUnicodeTables: mark all functions as nothrow 2015-01-10 08:42:55 +01:00
.gitattributes Update the git-archive export options 2012-09-07 15:39:31 +02:00
.gitignore Remove qtdemo from gitignore 2014-09-17 12:38:55 +02:00
.qmake.conf Enable -Werror for all of qtbase 2013-09-04 01:50:10 +02:00
.tag Update the git-archive export options 2012-09-07 15:39:31 +02:00
configure Merge remote-tracking branch 'origin/5.4' into dev 2015-01-21 11:10:14 +01:00
configure.bat Update license headers and add new license files 2014-09-24 12:26:19 +02:00
header.BSD Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
header.FDL Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
header.LGPL Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
header.LGPL3 Android: Don't include Apache code under LGPLv2 license 2014-10-02 05:59:17 +02:00
header.LGPL21 Added header.LGPL21 2014-08-23 07:17:35 +02:00
header.LGPL-ONLY Update copyright year in Digia's license headers 2013-01-18 09:07:35 +01:00
INSTALL Doc: Update links in INSTALL file 2014-01-16 20:37:25 +01:00
LGPL_EXCEPTION.txt Change copyrights from Nokia to Digia 2012-09-22 19:20:11 +02:00
LICENSE.FDL Initial import from the monolithic Qt. 2011-04-27 12:05:43 +02:00
LICENSE.LGPLv3 Update license headers and add new license files 2014-09-24 12:26:19 +02:00
LICENSE.LGPLv21 Update license headers and add new license files 2014-09-24 12:26:19 +02:00
LICENSE.PREVIEW.COMMERCIAL Update LICENSE.PREVIEW.COMMERCIAL license 2013-06-03 20:04:26 +02:00
qtbase.pro remove nonsensical claim about contains() 2014-11-13 14:33:16 +01:00
sync.profile ANGLE: upgrade to 2.1~07d49ef5350a 2014-08-05 16:43:22 +02:00