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

Lock revenue variable, Demonstrate that your program (include the program o...

Demonstrate that your program (include the program output as part of the final report) can produce the correct output with the following parameters. For each case comment if the ou

Advanced synchronization, Synchronization serves two purposes: 1) to ensure...

Synchronization serves two purposes: 1) to ensure safety for updates on shared data (e.g. to avoid races conditions), and 2) to coordinate and order actions taken by threads (e.g.

Explain the spawnlp functions used in the netware, Explain the Spawnlp Func...

Explain the Spawnlp Functions Used in the NetWare Spawnlp(flags, execName, arg0,...)  The Spawnlp function is used to load  a NetWare executable file (NLM) specified by exec

What do you mean by reference counts, Q. If each the access rights to an o...

Q. If each the access rights to an object are deleted the object can no longer be accessed. At this stage the object should also be deleted and the space it occupies should be ret

What is meant by the phrase thread-safe, The term thread-safe in computer p...

The term thread-safe in computer programming describes that routine or portion of the program that may be called from multiple programming threads without uncalled for interactions

Networking and distributed systems, Networks and operating systems have a l...

Networks and operating systems have a lot of overlap. In this course, however,we are not going to discuss networking in detail, but rather focus on the networking abstractions prov

Explain lru enhanced second chance algorithm, Enhanced Second chance algori...

Enhanced Second chance algorithm In this a modify bit is as well used. Now if the ordered pair of reference and modify is (0,0) neither recently used nor modified - the best

Definition of operating system, Q. Definition of Operating System? Defi...

Q. Definition of Operating System? Definition of Operating System: • An Operating system is a program which controls execution of application programs and acts as an interfa

Batch oriented and interactive operating system., properies of Batch orient...

properies of Batch oriented and interactive operating system.

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