In concurrent programming, a monitor is a synchronization construct that allows threads to have both mutual exclusion and the ability to wait (block) for a certain condition to become true. Monitors also have a mechanism for signalling other threads that their condition has been met. A monitor consists of a mutex (lock) object and condition variables. A condition variable is basically a container of threads that are waiting on a certain condition. Monitors provide a mechanism for threads to temporarily give up exclusive access in order to wait for some condition to be met, before regaining exclusive access and resuming their task. Another definition of monitor is a thread-safe class, object, or module that uses wrapped mutual exclusion in order to safely allow access to a method or variable by more than one thread. The defining characteristic of a monitor is that its methods are executed with mutual exclusion: At each point in time, at most one thread may be executing any of its methods. Using a condition variable(s), it can also provide the ability for threads to wait on a certain condition (thus using the above definition of a “monitor”). For the rest of this article, this sense of “monitor” will be referred to as a “thread-safe object/class/module”. Monitors were invented by C. A. R. Hoare and Per Brinch Hansen, and were first implemented in Brinch Hansen’s Concurrent Pascal language.
Monitor
By Jamey EkinsJamey Ekins
Hey there, I'm Jamey, and I've been an animal lover for as long as I can remember. Growing up on a 50-acre farm in Ontario, Canada, I was surrounded by a menagerie of furry friends, from beloved cats and dogs to goats, horses, cows, and even chickens. Now, I call Victoria, British Columbia my home, and my heart belongs to my adorable Balinese cat, Milo. When I'm not editing blog posts here at TechnoMEOW, I enjoy helping solo entrepreneurs with their passion projects and online marketing. Over the years, I've also ventured into creating and selling various blogs. Beyond the digital world, I'm an avid crochet and knitting enthusiast and share my crafty creations on my blog, doublecrochet.com.
Updated On 12.02.2024
Leave a Comment