:: Re: [DNG] Wirth's law
Inizio della pagina
Delete this message
Reply to this message
Autore: Didier Kryn
Data:  
To: Simon Walter, dng
Oggetto: Re: [DNG] Wirth's law
Le 23/07/2016 10:49, Simon Walter a écrit :
> On 07/23/2016 05:42 PM, Didier Kryn wrote:
>> Le 22/07/2016 18:21, Brian Nash a écrit :
>>> For example, when I discovered multithreading, all my programs used it
>>> in some way, even when it was unnecessary.
>>
>> I sometimes use multithreading, but never mutexes. Mutex can be harmless
>> if there's only one. Otherwise better use select()/poll() or you'll
>> waste time or even dead-lock. It's amazing how the old select() paradigm
>> is so much better than the modern mutex. I see mutex as an invention to
>> relieve the programmer from thinking.
>
> Really? I must be pretty stupid because I have think extra hard when
> using mutexes... :(


     Sorry if I hurted you. Maybe you thought hard to understand how to 
not dead-lock.


     The principle is to protect shared variables in such a way that you 
can then roll every thread as if it was running alone - this is what I 
meant by "relieve from thinking". With select() you must keep in mind 
the interactions between the threads, and all your program is organized 
around these interactions, with only one wait point per thread for all 
possible events; therefore no dead-lock.


     Didier