Re: checking return value of pthread_mutex_lock ...



In article <1148482341.794829.235420@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
<iler.ml@xxxxxxxxx> wrote:
Of these three, which coding recommendation would be better:

1. Always check return value from pthread_mutex_lock
[even if it makes code longer and less readable ]

If you have code that can actually do something useful with the non-0
returns from pthread_mutex_lock, that's impressive.

2. Never bother checking return value of pthread_mutex_lock

Lotta code out there like this. It's somewhat hazardous.

3. Do not check return value of pthread_mutex_lock in release build;
and do assert return value of thread_mutex_lock in debug build.

"Fly what you test; test what you fly."

4. Wrap pthread_mutex_lock in a function that abort()s (or similar)
on error return.

At least you'll get a core that might give you a start at debugging
whatever corrupted your mutex.
--
Steve Watt KD6GGD PP-ASEL-IA ICBM: 121W 56' 57.8" / 37N 20' 14.9"
Internet: steve @ Watt.COM Whois: SW32-ARIN
Free time? There's no such thing. It just comes in varying prices...
.