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

Assignment Help:

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


Related Discussions:- Program of calculator and controller - fork, exec, and wait

Correct the code for visitor and vehicle portion, Gopher Gallery consists o...

Gopher Gallery consists of a shopping mall and a cart ride that covers the 150 acre habitat. There are m visitors and n single-person vehicles. Visitors stroll around the mall at t

Explain the concept of mutual exclusion, Question 1: (a) Discuss about...

Question 1: (a) Discuss about the evolution of operating systems from mainframe batch systems to mainframe time sharing systems. (b) Explain your understanding of the "sus

What are the issues in designing a network-scalability, Scalability : ...

Scalability : Scalability is the competence of the system to adapt to increased service load. A scalable system will respond more gracefully to increased load than a non-sc

What disadvantages are there to this two-level directory, What disadvantage...

What disadvantages are there to this two-level directory? Without other provisions, two users who require cooperating with each other are hampered in reaching every other's fi

Write note on process, Write note on process, process state? A process ...

Write note on process, process state? A process is in excess of the program code which is sometimes known as text section. It as well includes the current activity as represent

Explain rehashing to handle collision, Explain Rehashing to Handle Collisio...

Explain Rehashing to Handle Collision Rehashing:  Re-hashing schemes make use of a second hashing operation while there is a collision. If there is an additional collision, we

What resources are utilized when a thread is created, Q. What resources are...

Q. What resources are utilized when a thread is created? How do they vary from those used when a process is created? Answer: For the reason that a thread is smaller than a pr

Computer, what is an operating system?

what is an operating system?

What is a two state process model?, What is a two state process model? ...

What is a two state process model?   At any time a process is being implementing by a processor or not. Therefore a process may be in Running or not running state. When an Ope

Develop a utility in c programming, Develop a utility in C language which w...

Develop a utility in C language which will run in Linux operating systems to display following properties of the system: ? Processor speed ? Ram size ? Computer name ? System time

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd