[M3devel] variations of waitpid..?
Olaf Wagner
wagner at elegosoft.com
Fri Jan 2 11:27:24 CET 2009
Quoting Tony Hosking <hosking at cs.purdue.edu>:
> If someone uses waitpid they get what they paid for.
It is so long ago that we wrote those sysutils routines...
They have only ever be used in simple command line utilities (like cm3)
without much concurrency, I think. If there is potential for deadlocks
and bad performance, we should at least document that in the interfaces.
I am not up-to-date wrt. the M3 system interfaces and threads
implementation: is there a way for a thread to wait for the exit code
of another process without blocking other threads? If so, I'll adapt
the sysutils code... If not, can we introduce such an interface in
m3core/libm3?
Olaf
> On 1 Jan 2009, at 06:24, Jay wrote:
>
>>
>> You mean, this function is easy to misuse?
>>> People who declare their own <*EXTERNAL*>
>> Like waitpid exposed from m3core?
>>
>> waitpid is already easy to misuse, on a userthread system, leading
>> to possible (though I think rare) deadlock.
>> It is easy to misuse on pthreads, lead "just" to bad performance,
>> and in fact I believe cm3 is doing this, via sysutils.
>> This at least guides you between two patterns of use, and fix the
>> perf of cm3/sysutils.
>>
>> On a userthread system, waitpid(pid, flags = 0) waits for the child
>> process, with all parent threads suspended.
>> Generally I doubt the child depends on parent threads progressing,
>> but, yeah, that could deadlock, like if a parent thread is waiting
>> to a file or stdin of the child, or reading a child's stdout.
>>
>> The various uses do waitpid(pid, flags = nohang) and then sleep and
>> try again.
>>
>> pthreads just uses waitpid(pid, flags = 0) and all threads keep running
--
Olaf Wagner -- elego Software Solutions GmbH
Gustav-Meyer-Allee 25 / Gebäude 12, 13355 Berlin, Germany
phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95
http://www.elegosoft.com | Geschäftsführer: Olaf Wagner | Sitz: Berlin
Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194
More information about the M3devel
mailing list