开发者

An unexplained pattern

Currently I'm reading some documentation written by another and I'm confused. A lot of it is about the multi-threading synchronization that has been implemented in the project for which this documentation is written.

In this project this programmer implemented a few classes that control the critical sections that are being used throughout the application.

Its just a bunch of classes that keep track of which thread has what critical section and is a wrapper around the native Win32 CRITICAL_SECTION structure.

Then there's the classes ending in -Visit which are actually used in the application and will check if a critical section has been entered a thread already before it ent开发者_如何学JAVAers.

This programmer calls it the 'Acquisition design pattern', I was wondering if there is such a pattern in existence and might it be called something else then what this programmer calls it, as I cannot find the pattern under this name anywhere?

I know I haven't gone into great detail, but that's about as much detail as I can go into.


When I implemented classes like this, its purpose was as follows:

  • Wrap the O/S primitives (e.g. critical sections)
  • Log their use
  • Detect deadly embrace, by keeping track of which threads owned which locks, and testing for deadly embrace before acquiring each lock
  • Instrumenting to predict-and-therefore-avoid deadly embrace, by keeping track of the sequence in which locks were acquired by threads (e.g. lockA followed by lockB), remembering this as the 'usual sequence', and then warning if a thread ever aquired locks in not-the-usual-sequence (e.g. lockB followed by lockA).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜