From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Lunn To: eCos Disuss Subject: Re: [ECOS] Nested calls to Mutexes Date: Wed, 21 Mar 2001 06:26:00 -0000 Message-id: <20010321145908.A2716@biferten.ma.tech.ascom.ch> References: <3AB8AFA1.3D50C070@redhat.com> X-SW-Source: 2001-03/msg00319.html > I disagree with this statement. It is a *common idiom* to have > routines that needs to "lock" some access to start calling other > routines that "locks" the mutex again. To me this is dangerous. Mutex's are used to protect state information. I lock the mutex when im want to modify the state information. The locked mutex indicates the state information may not be consitent. Now you want the thread that locked the mutex to be able to call other functions that also want to modify the state information. Those functions have to be aware the state information could be inconsitent. It cannot trust the information. Any changes it makes could also make the other function which locked the mutex also go wrong. You strongly tie the two functions together. Unless you know that this is happening its very easy to make a mistake and create subtle bugs which are hard to track down. I say eCos is correct. It should throw an assertion when this happens. I then know i have this sort of relationship going on and i need to redesign my code, If you do want the opertunity to shoot yourself in the foot, you could modify your local copy of eCos. You have the source! Andrew