Alternatively, you can just click here
The main program will fork a child for each source file and the child will create an object file by invoking the C compiler as in:
cc -c filename.cThe parent process will wait for all of the children to finish and if they are all successful, it will link the object files to produce the executable by invoking the C compiler as in:
cc -o executable file1.o file2.o ...The children should do the compile concurrently. You must find a way for the parent to determine whether the children were successful. All error messages should go to the screen.
Answer the following questions:
Write a program, link_it which takes command line arguments like the comp_link program. If first prints its process ID. Then it waits for the appropriate number of SIGUSR1 signals and then links the files together producing an executable.
Test your programs by compiling and linking three modules together by first starting link_it and then calling three copies of compile_it, one for each module. Run all programs from the same directory, but in different windows.
Note that link_it does not exit oif a module has a compile error. This allows for the correction and recompilation of that module without restarting link_it.
Answer the following question:
Write a daemon process, compile_any, which takes one command line argument, the name of a named pipe, and prints its process ID. It then waits for a SIGUSR1 realtime signal and when it comes in, forks a child process to compile a C source file into an object module. After the fork, it should wait for additional signals to come in so it can start other compiles. The child reads a filename from the named pipe which was the command line argument and sends a SIGURS2 signal back indicating that the read from the pipe was complete. It gets the process ID of the process to send to from the information in the realtime SIGURS1 signal its parent received. The child then creates an object module for that file. When the compilation is done, it sends a realtime SIGUSR1 signal back as in Part 2, but this time the info field indicates whether the compile was successful. The child then exits.
Write a main program, par_compile which takes 4 or more command line arguments. The first argument is the process ID of the compile_any daemon, the second is the name of a named pipe, and the others are as in Part 1. This program causes compile_any to compile the indicated files and notify it when each compile is done as described above. When all are successful, it links the modules. If one or more of the modules does not compile successfully, it exits with an appropriate message.
Answer the following questions: