Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Newsgroups: comp.lang.c,comp.programming.threads From: John Tsiombikas Subject: Re: Trivial C11 threads.h wrapper (public domain) References: <50646436$0$13270$4fafbaef@reader2.news.tin.it> User-Agent: slrn/pre1.0.0-18 (Linux) Message-ID: Date: 27 Sep 2012 15:58:16 GMT Lines: 32 Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 83.169.41.117 X-Trace: news.sunsite.dk DXC=3c?Y`omZoi9\:k25BLkF8;YSB=nbEKnk;4jUYP[]DMM6E0=08en@m@76EJNJ\54UW;TIG4S7l5;F;elf:afgd\H:d1Q_V1=0FK5]01T`Rm1cH8 X-Complaints-To: staff@sunsite.dk Xref: csiph.com comp.lang.c:26726 comp.programming.threads:1100 On 2012-09-27, Lorenzo Beretta wrote: > I haven't read it carefully enough to count as proofreading... most of > it seem to make sense, except for a couple of things: > 1. pthread_create can return EAGAIN, isn't it almost the same as thrd_nomem? I though about that for a bit while writting it, but after reading the pthreads manpage and the C standard a couple of times, I decided it's probably not the same error, and I thought it would be best to just leave thrd_nomem out. Might be wrong, I'll go through them again. > 2. pthread_mutex_timedlock sucks badly -- even microsoft got it right! > Try the following program and try not to scream when you realize > *why* it's not doing what you'd expect :) > > ... > const int s = 5; > ... > t.tv_nsec = 0; > t.tv_sec = s; > /* puke! */ > printf("timed_lock(%d) = %d\n", s, pthread_mutex_timedlock(&m, &t)); *gasp* ... it's absolute time ?! I must admit I never used timedlocks... I suppose that makes it easier to ask it to try locking the mutex until next friday at 3 o'clock or something :) -- John Tsiombikas http://nuclear.mutantstargoat.com/