Assignment title: C Programming
Question
C Programming in Linux
Q
C programming in LinuxThere are four commands for mini-MoSP as follows:
1) sum(parameter1, parameter2, …)
2) lcm(parameter1, parameter2, …)
3) bprime(paramter1, parameter2, …)
4) quit
First three commands are mathematical operations and the last command is to quit the program. To evaluate each command, user's input will be parsed and the checked whether it is correctly entered. Only when the input satisfied the syntax, it will be executed.
a. Creation of Child Process for Each Command
Each mathematical command is executed on a child process that is created by fork(). In the child process block, students should implement function(s) that can complete the mathematical command. While it is running, the parent process should wait and will continue after it completes all jobs.
b. Multithreading in Child Process
Within a child process, threads should be created and joined to execute desired operation(s). Use pthread library and compile thread option (-pthread) as shown in Figure 1.
2
CS5500 sec 13915
B. Complete Program
mini-MoSP should continue operating until user enters quit command. If the program ends by other commands or any other reasons, it will be considered bugs. And it should show proper and necessary messages when user enters any commands, either they are correct or not, so that he or she can know what to do next. Students who fail to do this interaction with user will lose points.
C. Exception Handling
mini-MoSP must catch errors when compiling and running it. The program should handle the following errors:
a. if user enters wrong commands
b. if user enters a command in incorrect syntax
c. if user's inputs cause exception (e.g., no prime numbers for bprime command)
These errors are examples and students should try to catch other errors that may occur. Failure to catch and handle them will take off points.
D. File Name
Main file (containing main function) should be named in the following format: