The application must be designed using multiple processes. At least the following 5 processes shall be included (note that the first process spawns the other processes at runtime):
1. A Startup and Monitor process that sets up any common variables (e.g. pipes and/or semaphores), spawns the other processes (including the simulator) using the POSIX fork() call and monitors the other processes for expected or unexpected termination.
As each child is spawned, the Startup and Monitor process shall print the name (e.g.“Controller’) and pid of the process.
When a child of the Startup and Monitor process terminates, the Startup and Monitor process shall print the name and pid of the process which has terminated and the associated termination status code.
The child processes spawned at startup shall overlay themselves using the POSIX execl()call, passing any required command line arguments and using relative file paths to executables.
As far as possible, all messages which are to be printed by the Startup and Monitor process shall be sent via an anonymous pipe to the Display process for printing. This will not always be possible e.g. before the Display process has been spawned and has
overlayed itself, in which case it is acceptable for the Startup and Monitor process to print directly to the standard output.
2. A Controller process to control the quadcopter. The requirements for this process are basically the same as those specified in Assignment 1 Part A and Part B, so you do not need
to change very much in terms of functionality for this process. However, any text to be printed shall not be printed directly to the standard output, rather it shall be relayed to the
Display process via an anonymous pipe for printing.
3. A Display process to display messages received via anonymous pipes from the Startup/Monitor and Controller processes to the standard output. The rationale for a separate Display process is that corruption can occur if multiple processes attempt to print to a single
terminal window simultaneously or near simultaneously, therefore all display output should be handled by a single process as far as possible.
4. The Simulator process which simulates the operation of the quadcopter. Because the simulator from Assignment 1 prints almost identical information to the controller, and because there will only be a single terminal window in Assignment 2, it is not required that
the Simulator process prints any information directly or sends any information to the Display process via an anonymous pipe or any other means of IPC. Some other source code changes will be required to the Simulator process to support the Battery Recharge process because the simulator currently maintains its battery percentage value independently of the corresponding value stored in the shared memory segment (i.e. it currently writes to the battery percentage field in shared memory, but does not read from it).
5. A Battery Recharge process to effectively reduce the quadcopter battery discharge rate while in flight using energy gleaned from a solar panel. This process shall meet the following
ELE3307 Real-Time Systems Semester 2, 2019
Page 3 of 5
It shall add to the current battery charge remaining at a rate of 0.2% per second of simulation time that the quadcopter is at its flight height (we will just assume it is always sunny for this assignment). Therefore, if the battery charge remaining percentage at
simulation time t seconds is e(t), then at simulation time t+Δt seconds it will be e(t+Δt) = e(t) + 0.2 * Δt - d(Δt) where d(Δt) is the amount of battery discharge caused by hovering/flying over the same time interval.
It shall not add to the battery charge remaining if the quadcopter is not at flight height.
You need to consider the synchronization requirements for the whole program in your design because no synchronization was employed at all in Assignment 1. Selective use of synchronization is important because if you use synchronization where it is not really needed, you may slow down the operation of your program considerably. Explain briefly your synchronization design in your report. You may it easier or even necessary to use named POSIX semaphores rather than unnamed
POSIX semaphores because of the use of process overlaying in the assignment.