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:
newintegratedtemp
previousintegratedtemp sumofclienttemps;
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:
newnodetemp
previousnodetemp newintegratedtemp;
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 TEMPERATURE:
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:
After the monitor process determines that the system is stable ie 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 TERMINATING...
assuming a node with the identifier 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 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 mqunlink any message queues that could have remained after abnormal terminations egC of the past runs of the monitor, since the queues are persistent,
create and configure using mqopen 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 mqreceive 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 mqsend 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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
