2. In a game called DuckHunting, players must shoot the ducks as they appear. A binary...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. In a game called DuckHunting, players must shoot the ducks as they appear. A binary file called "scores.dat" contains a sequence of 4 player's scores. Each record (a score) consists of the C structure: struct score{ int duckskilled; int ducks Missed; int points; int rank; } Write a C-program that calculates the total points gained and the rank of each player. Your program should use two processes, A and B, where: Process A calculates the number of points each player scored, and updates points in each data structure. Two points are awarded for each duck killed and 1 point is taken away for each duck missed. Process B calculates the rank of each of the 4 players, and updates rank in each data structure Use semaphores to ensure that the processes complete the task correctly, that is, both synchronization of the processes and protection of the critical region are required. The use of pipes are not permitted. [10 marks] 2. In a game called DuckHunting, players must shoot the ducks as they appear. A binary file called "scores.dat" contains a sequence of 4 player's scores. Each record (a score) consists of the C structure: struct score{ int duckskilled; int ducks Missed; int points; int rank; } Write a C-program that calculates the total points gained and the rank of each player. Your program should use two processes, A and B, where: Process A calculates the number of points each player scored, and updates points in each data structure. Two points are awarded for each duck killed and 1 point is taken away for each duck missed. Process B calculates the rank of each of the 4 players, and updates rank in each data structure Use semaphores to ensure that the processes complete the task correctly, that is, both synchronization of the processes and protection of the critical region are required. The use of pipes are not permitted. [10 marks]
Expert Answer:
Answer rating: 100% (QA)
Below is a simplified example of a Cprogram using semaphores to implement the described functionalit... View the full answer
Related Book For
Operations Management An Integrated Approach
ISBN: 9781119497387
7th Edition
Authors: R. Dan Reid, Nada R. Sanders
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
In Problem 12.4 on page 423, you used the percentage of alcohol to predict wine quality. The data are stored in VinhoVerde. From the results of that problem, b 1 = 0.5624 and Sb 1 = 0.1127. a. At the...
-
Use either a CAS or a table of integrals to find the exact area of the surface obtained by rotating the given curve about the x-axis. 21. y 1/x, 1
-
Prairie Flower Cereal, Inc., is a small but growing producer of hot and ready-to-eat breakfast cereals. The company was started in 1910 by Gordon Thorson, a successful grain farmer. You have been...
-
Bert C. Roberts Jr. was chairman of WorldComs board of directors. Immediately before that, he had been chairman of MCI, which WorldCom acquired on September 14, 1998, in a transaction valued at...
-
As part of the settlement for a class action lawsuit, Hoxworth Corporation must provide sufficient cash to make the following annual payments (in thousands of dollars): The annual payments must be...
-
The wave function associated with standing waves established in a 5.00 m long light-weight rope is y = 0.00300 sin(x)cos(110t) where x and y are in meters and t is in seconds. (a) How many...
-
Belltown Athletic Supply (BAS) makes game jerseys for athletic teams. The F. C. Kitsap soccer club has offered to buy 100 jerseys for the teams in its league for $15 per jersey. The team price for...
-
A manufacturer that ships goods made at its Brazilian plants to markets in foreign countries views a weaker Brazilian real (vis-a-vis the currencies of the countries to which it is exporting) as an...
-
The activities of a central motor pool that provides and services vehicles for the official use of municipal employees from several city departments should be accounted for in a. an Agency Fund. b....
-
Arbitrage may be best defined as . interest paid on short-term financings. a. any interest earned on investments in a Capital Projects Fund. b. interest earned in excess of interest paid on...
-
On January 1, 20X7, Clyde County issued $100 million of 5%, 20-year bonds at 102. Interest is payable semiannually. The proceeds were restricted for the construction of a new county water...
-
Generally, sales tax revenues should be recognized by a local government in the period a. in which the local government receives the cash. b. that the underlying sale occurs, whether or not the local...
-
Which of the following statements is true concerning the accounting and financial reporting for capital leases in governmental funds? a. Governmental entities apply essentially the same criteria as...
-
Short Term Rental Pty Ltd (STR) manages short-term rental accommodation properties on behalf of owners. Initially, it started managing small city apartments but has recently expanded to include...
-
(a) As Section 17.3 discusses, high-frequency sound waves exhibit less diffraction than low-frequency sound waves do. However, even high-frequency sound waves exhibit much more diffraction under...
-
Which of the following is an output of material requirements planning (MRP)? a) Inventory records b) Schedule of replenishment orders c) Bill of material file d) Master production schedule
-
Use the longest task time rule to balance the assembly line described in Table 10-21; the line can produce 50 units per hour. a) What is the cycle time? b) What is the theoretical minimum number of...
-
1. How will you develop this forecasting process? 2. Which methods will you use? What variables will be considered? 3. Are there conditions under which the analytics models should be adjusted by your...
-
You need to understand the approach described in question 3 in More Genetic TIPS before answering this question. A gene that is normally expressed in pancreatic cells was cloned and then subjected to...
-
Many researchers are interested in the transcription of protein-encoding genes in eukaryotes. Such researchers want to study mRNA. One method that is used to isolate mRNA is column chromatography....
-
The type of model building used by Pauling and by Watson and Crick involved the use of ball-and-stick units. Model building can now be done with computer software. Even though you may not be familiar...
Study smarter with the SolutionInn App