Program of calculator and controller - fork, exec, and wait, Operating System

Program of Calculator and Controller with the fork, exec, and wait system calls

The objective of this assignment is to get you to be comfortable with the fork(), exec(), and wait() system calls

For this assignment you will be creating two programs: Controller and Calculator  

Controller: The controller is responsible for using the

(1) fork() command to launch another process

(2) exec() command to replace the program driving this process, while also supplying the arguments that this new program (Calculator) needs to complete its execution.

(3) wait() command to wait for the completion of the execution of the process.

The Controller is responsible for launching 4 processes that it will load with the Calculator program.

Calculator: This program requires two arguments to complete its task. This program performs a simple modulo operation on the two numbers supplied to it and prints out the result.   

All print statements must indicate the program that is responsible for generating them. To do this, please prefix your print statements with the program name i.e. Controller or Calculator. The example section below depicts these sample outputs.

Requirements of Task 

1. The Controller should spawn 4 processes using the fork() command. 

2. The Controller needs to ensure that it completes one full cycle of fork(),exec() and wait()  for a given process before it moves on to spawning a new process. 

3. Once it has used the fork()command, the Controller will then print out the process ID of the process that it created. This can be identified checking the id returned from the fork() command.

4. Child-specific processing immediately following the fork() command then loads the Calculator program into the newly created process using the exec() command. This ensures that the forked process is no longer a copy of the Calculator. This exec() command should also pass 2 arguments to the Calculator program.  For this assignment, it is recommended that you use the execlp() command.  The man page for exec will give details on the usage of execlp().

5. Parent-specific processing in the Controller should ensure that the Controller will wait()  for the child-specific processing to complete.

6. When the Calculator is executing it prints out its processID; this should match the one returned by the fork()command in step 3.

7. The Calculator then completes, and prints the result of, the modulo operation on the two arguments that were passed to it in step 4. The operation that it performs on these arguments is argOne modulo argTwo.

8. Once the Calculator completes, the Controller gets out of its wait()  and proceeds to repeat step 2. The goal is to ensure that 4 child processes are created in total.  

Figure 1 below depicts the assignment scenario.

1532_Program of Calculator and Controller -  fork, exec, and wait.png

Posted Date: 3/4/2013 6:56:16 AM | Location : United States







Related Discussions:- Program of calculator and controller - fork, exec, and wait, Assignment Help, Ask Question on Program of calculator and controller - fork, exec, and wait, Get Answer, Expert's Help, Program of calculator and controller - fork, exec, and wait Discussions

Write discussion on Program of calculator and controller - fork, exec, and wait
Your posts are moderated
Related Questions
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4


Q. What is the use of the command interpreter? Why is it generally separate from the kernel? Answer: It reads commands from the user or else from a file of commands and execu

How do we overcome the disadvantages of the two-level directory? Give links from one user directory to another, creating path names; system files become available by letting th

Explain Components of conflict phase of dispatch latency The conflict phase of dispatch latency has two components 1. Preemption of any process running in the kernel. 2.

1. Suggest some mechanism(s) to lower the dispatch latency while scheduling for a real-time system. Also, discuss any trade-off or consequent constraint associated with it, if a

Write a note on deadlocks. The proper definition of deadlock A set of processes is deadlocked if every process in the set is waiting for an event that only a proces

Question : a) Describe the difference between the authentication of a user account on a peer to peer network and a client server network. b) Compare an end user account with

Translation Look aside Buffer In a cached system, the base addresses of the last few indexed pages is maintained in registers named the TLB that adds in faster lookup. TLB has

Why interrupt can be used? The majority of the different parts of the PC need to send information to and from the processor and they expect to be able to get the processor's at