This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: reentrant mutex


Nick Garnett wrote:
Jonathan Larmour <jifl at eCosCentric dot com> writes:


Nick Garnett wrote:

I would personally not like to see such a patch. It would not work
very well with condition variables and any system that mixed regular
and recursive mutexes would be very hard to debug.

I'm not sure it would make that much difference since they would be completely different types... I would agree that making a Cyg_Mutex have configurable behaviour would be bad and confusing. Similarly therefore, since condvars only take a Cyg_Mutex and not a Cyg_Recursive_Mutex (or whatever), it should be fine.


Mutexes without condition variables are not very useful. The two are
complimentary parts of a single synchronization mechanism. Taking the
patch idea to its logical conclusion, we would also need a set of
condition variables that took a recursive mutex. We would end up with
two independent parallel synchonization domains. That would be a
really nasty can of worms to open.

What, like cnt_sem and cnt_sem2 (or even bin_sem for that matter since that isn't in the kapi) ;-). Ditto mboxt and mboxt2.


I don't think having two (semantically different and differently named) primitives is a problem. The two cond vars could even share code easily enough, so it wouldn't cause any significant maintenance issue.

Anyway, I just want to be sure that defining a recursive mutex as a
completely different type would still not be acceptable.

I suspect that the only way of doing it is to add a runtime option to the mutex implementation to support recursion. However this would require some of the API to change and would need an up-to-the-elbows-in-blood-and-guts rewrite of the mutex and condition variable code, as well as lots of other bits of eCos. The degree of instability this would introduce is probably not worth it for a relatively minor change in external functionality.

I agree. If it should be done at all, it should be with a separate type.


Jifl
--
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine


-- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]