Question: Project Question: 1. You wll implement two programs in this project that are closely related. The first program is called ALU. This program accepts three


Project Question: 1. You wll implement two programs in this project that are closely related. The first program is called ALU. This program accepts three arguments from the command line. Two arguments are numbers while one argument is one of the opertions from +,-,,'x'. Your main function should read these arguments, if the number of arguments is not 3, then your program should return the value-9999 and exit. If number of arguments is 3, then your program should perform the operation between the two numbers and return the result of the operation. The second program is called CPU. This program will take 1 argument from the command line which will be a filename. Your program should open this file and read mathematical operations from each line. Each line of the file will have one number followed by an operation and then a second number. A sample file is given below. 2. 3 +6 12-4 3 x 10 4 24 3. For each line in the file, your program should fork a child process, in the child process execute the program ALU and pass it the three values that you read from this line as arguments. Once all lines have been executed, you will wait for the child ALU processes to finish execution and read the return values sent by these processes. You will output the result of the operations in a file called math.txt in the following format 3+6=9 12-4-8 3 x 10- 30 4 24 -not enough arguments Keep in mind that an operation might produce a floating point exception. For example the following is not possible mathematically 6/0 For operations like this, your program should report the following in the math txt file 6/0 -illegal operation You should NOT check for the numbers to be zero. You should get the exit status from the "wait" call and check if the program terminated due to an exception
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
