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++

Discussionkeyboard versus file input please respond to the

Discussion "Keyboard versus File Input" Please respond to the following: • Suppose you are designing a C++ application that needs to capture user input specifically via a keyboard or from a file. Determine the method tha ...

Discussionobject-oriented design please respond to the

Discussion "Object-Oriented Design" Please respond to the following: • Suppose you were required to write a C++ program that captures and stores data about automobiles that a small dealership in your city sells. Consider ...

Programming assignment image processing - pointers class

Programming Assignment: Image Processing - Pointers, Class & Dynamic Data This project is called "Image Processing" which will shrink an input image, convert a color image to gray image , add random noise to an image, ad ...

Assignment a random mazewrite a new c program with the

Assignment (a) Random Maze Write a new C++ program with the following functionality: The program writes a greeting on the screen. Then the program displays a maze of ASCII symbols on the screen. The maze consists of 8 ro ...

Create your own unique while-end repetition structure you

Create your own unique While-End repetition structure. You decide the theme. You should provide both the pseudocode and the flowchart of your example. Be sure to provide an overview of what your repetition structure is d ...

Write a program that reads numbers from cin and then sums

Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Construct three versions of this program, using the while, do - while , and for loops. Add the following to your program: ...

Computer applications divisionassignment c programmingstl

COMPUTER APPLICATIONS DIVISION Assignment: C++ PROGRAMMING STL Vector For this assignment, you will be starting with an example program that demonstrates the use of a STL vector. In addition to this, you may need to look ...

C-programmingcreate a c program that sorts a sequence of

C-Programming Create a C program that sorts a sequence of positive numbers using the bubble sort algorithm in an increasing or decreasing order based on the user's choice. The pseudo code for the bubble sort algorithm is ...

Computer sciencewhere do you think c and coding games in c

Computer Science Where do you think C++ and coding games in C++ is headed in the next five years? How about in the next 10 years? Do you think there are any significant improvements that need to be made to the code to en ...

Assignmentoverviewthis assignment consists of implementing

Assignment Overview This assignment consists of implementing an application using the techniques learned in the first half of the course. Examples on how to use file operations, random number generation, the standard tem ...

  • 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

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro