TP3 Monitors EN
TP3 Monitors EN
TP3 Monitors EN
Documentation
The concept of "monitor" can be used to synchronize processes using conditions (in the
multiprocessing module). See the documentation available in Moodle.
1/2
M1 Computers Science Parallelism
1. Propose a specification for a monitor that manages competing accesses of NBV voters to
these NBP booths.
2. Propose blocking and unblocking conditions as well as shared variables and conditions
associated with the monitor.
3. Implement this monitor using the ExtendedCondition class defined in the previous
exercise.
4. Write an application in which NBE voter processes use the operations of this monitor to
synchronize their accesses to existing NBI booths. We will consider that 1/ratio voters have
priority (for example by considering that voters for which id_voter % ratio == 0
have priority)
Reminder: If the displays are too fast, it is possible to delay the execution of a process for a few
microseconds or nanoseconds using the primitives:
time.sleep(secondes)
See the online manual for their use:
https://docs.python.org/fr/3/library/time.html#time.sleep
We can use a randomly generated value (see the functions random.rand and random.seed) to vary
the waiting times from one process to another.
https://docs.python.org/3/library/random.html
But, be careful, the timeout is not there to solve the problems of concurrent access to shared
variables. In other words: any execution of a parallel application must give a consistent result
without timeout!
2/2