Date: Sun, 31 Aug 2014 21:10:46 +0200 From: Jens Gustedt <jens.gustedt@...ia.fr> To: musl@...ts.openwall.com Subject: Re: [PATCH 7/8] add the thrd_xxxxxx functions Am Sonntag, den 31.08.2014, 13:02 -0400 schrieb Rich Felker: > On Sun, Aug 31, 2014 at 06:36:00PM +0200, Jens Gustedt wrote: > > EAGAIN from clone is clearly a distinct error condition than when it > > is on ENOMEM. I would not see it covered by what C11 expects as that > > error condition. So the EAGAIN from clone should go to thrd_error, I > > think, and not be merged with ENOMEM for the C threads implementation. > > I disagree here, at least unless you have a convincing argument for > this. EAGAIN from clone reflects a condition where a resource could > not be allocated. The reason (policy or inherent limits on a > particular type of resource, as opposed to just generally running out > of memory) doesn't seem to be relevant to applications, and I don't > see how thrd_error is any more appropriate than thrd_nomem for > reporting it. Certainly there are other cases where one type of > allocation (e.g. mmap for a thread) might fail where another (e.g. > malloc reusing freed memory on the heap) might fail, so I don't think > you can say that thrd_nomem is inappropriate if malloc would succeed. The convincing arguments come from the documentation, I'd say. C11 says The thrd_create function returns thrd_success on success, or thrd_nomem if no memory could be allocated for the thread requested, or thrd_error if the request could not be honored. (If this is a reasonable distinction of errors is a completely different question.) The man page for clone (whatever authority this has) says, among other things EAGAIN Too many processes are already running. ENOMEM Cannot allocate sufficient memory to allocate a task structure for the child, or to copy those parts of the caller's context that need to be copied. I have difficulties to read "lack of other resources" into the case for thrd_nomem. I see that EAGAIN is relatively well covered by thrd_error, but not very well by thrd_nomem. thrd_nomem is the catch-all-the-rest error, so I think that C11 permits to map EAGAIN together with eventually happening other exotic stuff on on it. Jens -- :: INRIA Nancy Grand Est ::: AlGorille ::: ICube/ICPS ::: :: ::::::::::::::: office Strasbourg : +33 368854536 :: :: :::::::::::::::::::::: gsm France : +33 651400183 :: :: ::::::::::::::: gsm international : +49 15737185122 :: :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt :: Download attachment "signature.asc" of type "application/pgp-signature" (199 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.