Re: checking return value of pthread_mutex_lock ...
- From: steve@xxxxxxxx (Steve Watt)
- Date: Wed, 24 May 2006 19:03:07 +0000 (UTC)
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...
.
- References:
- checking return value of pthread_mutex_lock ...
- From: iler . ml
- checking return value of pthread_mutex_lock ...
- Prev by Date: Re: output of client thread
- Next by Date: Re: output of client thread
- Previous by thread: checking return value of pthread_mutex_lock ...
- Next by thread: Re: checking return value of pthread_mutex_lock ...
- Index(es):