In formal terms, a monitor is an object which only allows one of its methods to
ID: 3678057 • Letter: I
Question
In formal terms, a monitor is an object which only allows one of its methods to be executed at once. Java, and ways to duplicate the same functionality.
What is the language’s fundamental high-level synchronization construct?
How does it relate to monitors as we defined them in class?
Does the language provide additional synchronization-related functionality? In brief, what?
How could you implement a class satisfying the monitor’s fundamental mutual exclusion property – that is, a class whose instantiated objects ensured mutual exclusion among their methods? Provide a code fragment as an example.
Could you mutually exclude critical sections smaller than an entire method without resorting to mutex locks? If so, how?
How would you implement condition variables as we described them in class? Provide a code fragment as an example.
Does the implementation differ if you need more than one condition variable? If so, how?
Explanation / Answer
1) Semaphores is the language’s fundamental high-level synchronization construct.
2) A semaphore is a simpler construct than a monitor because it’s just a lock that protects a shared resource – and not a set of routines like a monitor. The application must acquire the lock before using that shared resource protected by a semaphore.
3)
4)