Question: Develop a dynamic distributed system as a network consisting of some number of nodes and a centralized monitor. The nodes should report their temperatures to

Develop a dynamic distributed system as a network consisting of some number of nodes and a centralized monitor. The nodes should report their "temperatures" to the monitor which, after receiving all reports and calculating an integrated "modulating temperature", sends feedback to the nodes. The feedback may be an instruction to:
modify the node temperature using the old temperature and the received integrated temperature included in the feedback from the monitor, or
stop processing in case of detecting no temperature changes in any of the nodes (effectively, this feedback shuts down the whole system).
The system is a feedback loop that ceases once there are no longer any changes in every single node for a single round.
The monitor process should calculate the integrated temperature following this formula:
new_integrated_temp
=(2* previous_integrated_temp + sum_of_client_temps)/6;
That value is sent as part of the feedback to all nodes. Take care for type conversions in the formulae.
Each of the nodes then should calculate its own new temperature based on the following formula:
new_node_temp
=(previous_node_temp *3+2* new_integrated_temp)/5;
Given these two formulas, a system with four nodes (like the one shown in the examples) should stabilize in some reasonable time.
Each node process should print its temperature after the temperature is recalculated in response to the feedback from the monitor:
NODE 2 TEMPERATURE: 78
The monitor process also should print its temperature after a new integrated temperature is calculated based on the temperatures reported by the nodes:
MONITOR TEMPERATURE: 45
After the monitor process determines that the system is stable (i.e., no node changed its temperature) and sends feedback to the node processes informing them about the stability, it should print:
STABLE TEMPERATURE DETECTED.
MONITOR TERMINATING...
When a node process receives feedback from the monitor that the system is stable, it should print:
NODE 2 TERMINATING...
(assuming a node with the identifier 2) and then exit.
You must use POSIX Message Queues in the implementation. Please see the lab reading for details on how the mq_* functions work.
Create three files from scratch, monitor.c, node.c, and message.h. You must also make a CMakeLists.txt, do not compile by hand with gcc.
The monitor process has three phases:
Setup
Unlink the old monitor message queue (inbox) and create a new one
Create the node message queues (outboxes) and node processes
Feedback Loop
Receive node temperatures from the inbox
Calculate new integrated temperature
If 100% of nodes reported the same temperature as last time, go to the next phase. Otherwise, continue
Send the new temperature to all the outboxes
Teardown
Send a message to the nodes to quit
Clean up
The node process:
Opens the two message queues
Loop until monitor says the system is stable
end the current node temperature
Receive the update
If the system is stable, go to the next step. Otherwise, continue
Calculate new temperature
Report new temperature to monitor
Close down
The dynamic system should be composed of a single central monitor process, and a number of external node processes. The whole system should be started by running the monitor process that must:
remove (using mq_unlink()) any message queues that could have remained after abnormal terminations (e.g.,^C) of the past runs of the monitor, since the queues are persistent,
create and configure (using mq_open()) an afferent (incoming) message queue for accepting reports from the node processes,
for every node process, create and configure an efferent (outgoing) message queue for sending feedback to the corresponding node processes, and then
create (using fork()) and start (using execlp()) the node processes.
After creating the queues and the node processes, the monitor should enter the "regular" operation that consists of the loop in which it:
reads (using mq_receive()) the reports from all node processes identified by their identifier from the afferent reporting message queue,
computes the sum of the temperatures reported by the nodes processes,
saves the reported values for further tests on stability,
counts the number of processes that have not changed their temperatures,
exits the loop if none of the nodes changed its temperature in this round, and
otherwise, it continues to loop.
After the loop is exited, the monitor must send (using mq_send()) the termination notice to all node processes by setting the flag stable in the sent message to true, and then, it must remove all queues used in the program (since - as we already stated - they are persistent).
 Develop a dynamic distributed system as a network consisting of some

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!