pthread_mutex_timedlock with time in past

Peter Dufault dufault at
Sat Aug 28 17:08:21 UTC 2010

On Aug 28, 2010, at 10:24 , Joel Sherrill wrote:

> I was reviewing this code and wanted to
> make sure that ...
> + lock is busy (e.g. unavailable)
> + absolute time is in the past
> We should return ETIMEDOUT not EBUSY.
> The OpenGroup page is this but I am missing
> the exact phrase which tells us what to do.

"The *timeout shall expire* when the absolute time specified by abs_timeout passes, as measured by the clock on which timeouts are based (that is, when the value of that clock equals or exceeds abs_timeout), *or if the absolute time specified by abs_timeout has already been passed at the time of the call*."
The mutex could not be locked before the specified timeout expired."

I think those two imply you should return ETIMEDOUT.

Peter Dufault
HD Associates, Inc.      Software and System Engineering

More information about the users mailing list