Subj : Re: Linking without -lpthread doesn't fail?? To : comp.programming.threads From : David Schwartz Date : Fri Oct 07 2005 06:59 am "David Butenhof" wrote in message news:7gu1f.14123$zm1.5268@news.cpqcorp.net... > David Schwartz wrote: >> Frankly, I'm surprised it indicated the successful creation of a >> mutex and condition variable. I agree, it should not allow you to create >> a mutex and condition variable and then not time out. > The non-thread pthread stubs SHOULD allow you to allocate and initialize > both mutexes and condition variables. You should be able to lock and > unlock mutexes -- there's no chance of lock contention because there's > only one thread. Some might implement lock and unlock as empty stubs; > others might do consistency checking. If it indicates the successful creation of a mutex and condition variable, then it should support their semantics. Otherwise, it's lying when it said it succeeded. > You shouldn't be able to WAIT on a condition variable, because there's no > way the waiting thread could ever be awakened. But correct program logic > makes that irrelevant because there's no way a predicate could fail to be > satisfied (i.e., no reason to ever wait). Or at least, if there ever is a > reason/need to wait the program is completely broken anyway and will just > hang. Right except ... > Timed wait is a special case, though, because there is a common idiom of > treating ETIMEDOUT as the predicate condition, and that can be satisfied > without another thread. In MY non-threaded stubs, the function > pthread_cond_timedwait() would simply "sleep" until the timeout. Exactly. DS .