Ask Question, Ask an Expert


Ask C/C++ Expert

Home >> C/C++

“Base to Bombardier”
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
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.
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++

1 learner objectivesat the conclusion of this programming

1. Learner Objectives: At the conclusion of this programming assignment, participants should be able to: * Apply repetition structures within an algorithm * Construct while (), for (), or do-while () loops in C * Compose ...

Here are two examplesifcounter7continueifcounter7break1

Here are two examples: if(counter==7) continue; if(counter==7) break; 1. Write a for loop that counts only the odd numbers out of the first five numbers entered from the keyboard, but does not count (skips) the number 7. ...

Problem 1 you are tasked to write a program that outputs

PROBLEM 1 You are tasked to write a program that outputs the following amplifier system specifications: Voltage amplification: 25 Input voltage: 50 mV Power output: 2.5 W Bandwidth: 15 kHz Type: Class A a. For this progr ...

C program codeoverviewfor this assignment write a program

C++ program code Overview For this assignment, write a program that will simulate a single game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the die will determi ...

This program involves using stl listsfor this program you

This program involves using STL lists. For this program you will implement three functions whose prototypes are given below: list ::iterator mxIter(list ::iterator first, list ::iterator last); void selectSort(list & aLi ...

Computer programmingobjectives1 opening a file reading from

Computer Programming Objectives: 1. Opening a file, reading from file, writing to a file and closing a file. 2. Sequential access files handling. 3. Practice C++ programming problems. Note: Carefully read the following i ...

Q 1 write a c program to declare two integer one float

Q. 1 Write a C++ program to declare two integer , one float variables and assign 10, 15, and 12.6 to them respectively. It then prints these values on the screen. Q. 2 Write a C++ program to prompt the user to input her/ ...

Write a program that calculates mileage reimbursement for a

Write a program that calculates mileage reimbursement for a salesperson at a rate of $0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer re ...

Computer scienceprogram-write a c program that willpresent

Computer Science Program- Write a C++ program that will: Present the user with a menu of choices: 1. Random number 2. String 3. Type Casting 4. Integer Math Then, in an if-else if structure (or switch) write the code for ...

1 write a program to find the sum amp average of the given

1) Write a program to find the sum & average of the given numbers using the while loop. 2) Write a program in C to find the sum and average of the given numbers stored in an array of n values.

  • 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

A cola-dispensing machine is set to dispense 9 ounces of

A cola-dispensing machine is set to dispense 9 ounces of cola per cup, with a standard deviation of 1.0 ounce. The manuf

What is marketingbullwhat is marketing think back to your

What is Marketing? • "What is marketing"? Think back to your impressions before you started this class versus how you

Question -your client david smith runs a small it

QUESTION - Your client, David Smith runs a small IT consulting business specialising in computer software and techno

Inspection of a random sample of 22 aircraft showed that 15

Inspection of a random sample of 22 aircraft showed that 15 needed repairs to fix a wiring problem that might compromise

Effective hrmquestionhow can an effective hrm system help

Effective HRM Question How can an effective HRM system help facilitate the achievement of an organization's strate