For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > January 2008 > Re: Why not to auto Unlock the Mutex when Thread cancelled/die/exit









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Why not to auto Unlock the Mutex when Thread cancelled/die/exit
Joe Seigh

2008-01-22, 8:22 am

Raxit@MyKavita.com wrote:
> Hi,
>
> normally the execution flow of many threaded programs are like
>
> pthread_mutex_lock
> do some critical region stuff.
> pthread_mutex_unlock
>
> with many if-else-<or switch case or other stuff.+ Loop etc>
>
> No Doubt, Clear Code is Good, but what harm if library<or
> implementation> itself keep Tracks of Lock Acquired by Particular
> thread and when Threads cancel/exit, it will release/unlock all the
> locks acquired by that thread. <so even dummy programmers write buggy
> program, it will not buggy :) > <its like very much conceptually
> similar to Garbage Collection of Heap Memory.>
>
>


Or a collection of garbage which is what you'll end up with if
a program exits with the shared data in an inconsistent state.

Or you can look at it this way. If inconsistency is not a problem,
why use locks? They just slow things down.


--
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com