recursive close (mutex) vs non-recursive close (mutex)
posix allows mutexes recursive. means same thread close same mutex twice won't deadlock. impetus also needs clear twice, differently thread obtain mutex. systems ancillary pthreads also support recursive mutexes, nonetheless wish .
other apis (more high turn apis) also wholly offer mutexes, mostly called locks. systems/languages (e.g. cocoa objective-c) offer both, recursive non recursive mutexes. languages also wholly offer one. e.g. java mutexes always recursive (the same thread competence twice "synchronize" same object). depending thread functionality offer, carrying recursive mutexes competence problem, simply combined yourself (i already implemented recursive mutexes myself basement some-more rudimentary mutex/condition operations).
what i don't unequivocally understand: non-recursive mutexes good for? since i wish have thread deadlock fur same mutex twice? even high turn languages prevaricate (e.g. contrast deadlock throwing an difference does) wholly don't that. let thread deadlock instead.
is wholly cases, where i incidentally close twice wholly clear once box recursive mutex, harder problem, instead i have deadlock immediately where crude close appears? nonetheless couldn't i same carrying close opposing returned unlocking situation, where i'm certain i expelled final close opposing zero, i pitch an difference record problem? there any other, some-more useful use-case non recursive mutexes i destroy see? maybe only performance, non-recursive mutex rather faster recursive one? however, i tested inadequacy unequivocally big.
Comments
Post a Comment