[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Fixes for generic pthread_cond_*wait functions



phil-list redhat com schrieb am 11.03.03 12:57:39:
> 
> This patch fixes one error found by one of the test programs, plus
> another where the behaviour of the generic pthread_cond_wait function
> differs from the x86 version.  The first error is that
> pthread_cond_timedwait doesn't return an error (as it should) if it
> gets an error unlocking the mutex.  The second is that if
> pthread_cond_wait gets an error relocking the mutex, it doesn't return
> the error.  This patch fixes both.

IMO the right "fix" for the second one is nothing but abort(). 
Failure to reacquire the mutex when acting on cancelation aside 
for a moment (there is just no way to communicate any errors to 
the cleanup handler that is supposed to "adjust" application 
state/invariants-associated-with-mutex-and-canceled-waiter and
unlock the mutex), the standard says:

"RETURN VALUE

 Except in the case of [ETIMEDOUT], all these error checks shall 
 act as if they were performed immediately at the beginning of 
 processing for the function and shall cause an error return, in 
 effect, prior to modifying the state of the mutex specified by 
 mutex or the condition variable specified by cond."

And, BTW, speaking of cancelation and given that some form of 
async.cancel IS used "around" the futex-wait-call, I think that 
the entire condvar-cancel-handling is pretty much broken. Among 
various things I don't quite follow are, for example:

- a rather mysterious "cbuffer.oldtype" beast;

- lack of some measure(s) to ensure that a canceled thread does 
  NOT consume a "concurrent" signal -- "A thread that has been 
  unblocked because it has been canceled while blocked in a call 
  to pthread_cond_timedwait() or pthread_cond_wait() shall not 
  consume any condition signal that may be directed concurrently 
  at the condition variable if there are other threads blocked 
  on the condition variable."

Or am I just missing and/or misunderstanding something?

regards,
alexander. 

______________________________________________________________________________
Jetzt 52 verschiedene Briefpapiere fur Ihre E-Mails bei
WEB.DE FreeMail - http://freemail.web.de/features/?mc=021140





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]