lkml.org 
[lkml]   [2009]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[RFC][PATCH] sched_wait_block: wait for blocked threads
Date
Hi Ingo, Peter, all,

The attached patch is a prototype for a new system call which
allows threads to wait for other threads being blocked.

Its main use is to allow threading libraries to resume
executing more CPU-bound work when one of its threads is
blocked while not having to over-allocating threads in a
normal situation.

Benefit over asynchronous I/O is that a threadpool
thread that performs asynchronous I/O might not have
work enough in one item to keep the CPU busy during the
whole asynchronous operation and that not all operations
are async capable.
Giving control back to the library through a thread
waiting for the blocked one allows new workitems to be
executed as long as the former is blocked.

Code performing this wait could look like:
pid_t parent = ...;
while (waitpid(parent, NULL, WNOHANG) != 0)
{
if (sched_wait_block(parent, NULL) == 0)
{
// do work, possibly notify threadpool manager
// to start another thread blocked on this one
// first
}
}

Any feedback on the concept is much appreciated.

Regards,
Stijn Devriendt



\
 
 \ /
  Last update: 2009-11-15 20:07    [W:0.199 / U:0.816 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site