Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

“Base to Bombardier”
 
Objectives
 
In this lab, each student is to prepare a single program called prog9.c which has a “base process” which communicates with child processes acting as “bombers” that it creates. The student specifically explores:
 
• Handling processes by use of fork(), getpid()and wait()
 
• Handling signals by use of signal(),alarm()and kill()
 
• Opening and accessing a console window buffer
 
Operation
 
Before executing the program, the user should open four console (terminal) windows.
The first terminal window will represent the base, and the other three will represent the three bombers.
 
The first action of the program’s main loop is to discover how many terminals are open by trying to open all possible terminal number buffers (e.g. /dev/pts/1,/dev/pts/1 etc…) as a read only file.
Those that are open should be stored so that the first four found can be written to.
 
The main function of the air base is use fork() to spawn three child bomber processes which are to execute the same exact code, and a fourth child (without an associated terminal window) to receive input and while monitoring and signaling the bombers.
 
Each bomber is to be initialized to contain 50 gallons of fuel, six bombs, and to be a distance of zero miles from the base. An alarm() timer is to be installed and used which:
 
• Decrements the fuel by two gallons each second.
 
• Increments the distance from base by one mile every two seconds if going toward target, and decrements the distance from base by one mile every two seconds if returning to base.
 
• Reports the fuel amount, ordinance left, and distance from base every three seconds in the appropriate terminal. e.g. Bomber id to base, g gallons left, b bombs left, m miles from base.

System Programming Concepts
 
If a bomber ever runs out of fuel it should be terminated by exiting with an unsuccessful code. If a bomber drops its entire payload, it should begin returning to base. If it makes it back to base without running out of fuel, it should terminate with a successfully code.
 
Input/output
 
The program should accept the following input (where invalid commands should produce a suitable error message):
 
• bn – Orders plane n (n = 1 to 3) to drop a bomb.
 
• rn – Refuels plane n’s fuel tank to 50 gallons.
 
• kn – Terminates (kills) the plane n process.
 
• q – Exits the program.
 
Given the bn command, the base should send the signal SIGUSR1 to plane n. Upon receiving the signal SIGUSR1, the plane should print out that it (plane n) has dropped a bomb and then print how many bombs it has left. When the plane has no more bombs left, it should print that it has no more ordinance left and that it is returning to base.
 
Given the rn command, the base process should send the signal SIGUSR2 to plane n. Upon receiving the signal SIGUSR2, a plane should refuel, resetting its fuel value to 50 gallons. Whenever a plane’s fuel drops below 5 gallons, it should print the message “Mayday, mayday!” If a plane uses all its fuel before being refueled, the plane should send the signal SIGUSR2 to the base, print the message “Bomber n down. Pick us up in the drink.” and then exit. The base should respond with “Vaya Con Dios, Flight n” in its terminal window.
 
Given the kn command, the base should terminate the selected child process and note such in its terminal. Given the q command, the base should terminate all child processes and close the program.

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91629

Have any Question?


Related Questions in C/C++

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As