I am reading synchronization chapter in Operating system and am reading the topic "Monitors". I understand that monitors are high level language constructs. This makes me wonder if C provides something like monitor? Perhaps the library containing posix threads implementation should provide the monitor construct as well. Also, threads in C are not part of stl, right?
if yes, which header file/library contains it, a most elementary test program to use monitors and how the library implements monitors.
The book says a monitor type is an ADT - abstract data types. I wonder, does a C structure simulate a monitor data type?
Thanks,
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 false. Monitors also have a mechanism for signaling other threads that their condition has been met.
What is a monitor in OS? Monitors are a programming language component that aids in the regulation of shared data access. The Monitor is a package that contains shared data structures, operations, and synchronization between concurrent procedure calls. Therefore, a monitor is also known as a synchronization tool.
Some languages that do support monitors are Java,C#,Visual Basic,Ada and concurrent Euclid.
Monitor in Java Concurrency is a synchronization mechanism that provides the fundamental requirements of multithreading namely mutual exclusion between various threads and cooperation among threads working at common tasks. Monitors basically 'monitor' the access control of shared resources and objects among threads.
C has no notion of thread and doesn't provide monitors as syntactic structure.
the POSIX thread library is just a library. And C abstraction facilities are not powerful enough to allow monitors to be provided as library element. POSIX gives the primitive needed to build monitors.
STL is a C++ term (and not even a good one as it means different things for different people).
to implement a monitor in C, you'd need a structure whose content you keep private and has at least a mutex, and a set of functions operating on the struct which start by taking the mutex.
C doesn't even have support for threads, that's implementation specific. You'll need to use a library for your monitor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With