This program is going to implement a calculator. One process will be the user interface; it will prompt the user for an operator and two operands. The second process will perform the operation and pass the result back to the first process. Pipes will be used to transfer information between the two processes.
The parent and child are then going to work as a team, using the pipe for communication, to provide a simple integer calculator for the user.
The parent is going to prompt the user for an operation (+, -, *, /) and then 2 operands. The parent is going pass the operation and the operands to the child via the parentpipe. The child is going to perform the the operation and pass the results back to the parent via childpipe. More details are below.
The parent then must then prompt the user for 2 integer operands. Again, you must properly handle invalid input. If either input operand is invalid, prompt the user to reenter both operands. Only both operands should be reentered. At this point, the operator is valid.
The parent must then pass the operation followed by the 2 operands to the child by writing them in that order into parentpipe.
The parent must then read from childpipe to receive the results. After receiving the result of the operation from the child, the parent must display the results (remember to also display the operation and the operands) and present the menu again.
The parent must perform the above sequence until the user enters X to terminate the program. When X is entered, the parent must pass X on to the child via parentpipe, wait for the child to terminate, and then close parentpipe (the order is important here).
You will need the following include files:
sys/types.h
sys/ipc.h
unistd.h
iostream
wait.h
Note: this assignment must be done in C++
Your grade will be made up of the following:
a.Explain what is meant by asynchronous write.
b.Explain what is meant by blocking read.
These answers must be detailed and explicit.
Maintained by Barbara Bracken
Last Modified 11/07/2024
This page is copyright © by Barbara Bracken