a) Write a C program to Implement a system of three processes which read and write...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
a) Write a C program to Implement a system of three processes which read and write numbers to a file. Each of the three processes P1, P2, and P3 must obtain an integer from the file (these instructions must be executed 200 times). The file only holds one integer at any given time. Given a file F, containing a single integer N, each process must perform the following steps (25 points): 1. Fork two processes For 200 times: 2. 3. 4. 5. 6. 6819 7. 8. 9. Open F Read the integer N from the file Close F Output N and the process' PID (On the screen) Increment N by 1 Open F Write N to F (overwriting the current value in F) Close F b) Briefly describe why the processes P1, P2, and P3 obtain/read duplicates of numbers (why does a particular integer x appear in the output of more than one process)? (3 points) c) Suggest a solution (you do not need to implement it) to guarantee that no duplicate numbers are ever obtained by the processes. In other words, each time the file is read by any process, that process reads a distinct integer. (2 points) a) Write a C program to Implement a system of three processes which read and write numbers to a file. Each of the three processes P1, P2, and P3 must obtain an integer from the file (these instructions must be executed 200 times). The file only holds one integer at any given time. Given a file F, containing a single integer N, each process must perform the following steps (25 points): 1. Fork two processes For 200 times: 2. 3. 4. 5. 6. 6819 7. 8. 9. Open F Read the integer N from the file Close F Output N and the process' PID (On the screen) Increment N by 1 Open F Write N to F (overwriting the current value in F) Close F b) Briefly describe why the processes P1, P2, and P3 obtain/read duplicates of numbers (why does a particular integer x appear in the output of more than one process)? (3 points) c) Suggest a solution (you do not need to implement it) to guarantee that no duplicate numbers are ever obtained by the processes. In other words, each time the file is read by any process, that process reads a distinct integer. (2 points)
Expert Answer:
Answer rating: 100% (QA)
a Heres a simplified C program that implements the described system with three processes P1 P2 and P... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these computer network questions
-
A short write-up about who the presidential candidates were for 2020 and what forms of media, including social media, you witnessed. Include them in your write-up as well as if there are any of the...
-
You are told that A and B are two events, such that P(A) = 0.59, P(B) = 0.21, P(A and B) = 0.1 What is the value of P(B given A)? Give your answer to two decimal places. Do NOT give you answer as a...
-
. A vertical pole that is 2 meters tall casts a shadow that is 1.5 meters long. Nearby, at the same time, another vertical pole casts a shadow that is 6.5 meters long. How tall is this pole? a. Make...
-
Why is Supplier Relationship is important to a business. explain
-
In this assignment, you will analyze the implications of an ethical issue according to your worldview. Write a essay in which you analyze ethical thinking and use values-based decision making to...
-
Greydog Bus Company operates buses between Boston and Washington, D.C. A bus trip between these two cities takes 6 hours. Federal law requires that a driver have more than 4 hours between trips. A...
-
Which industrial transducer does not require a power supply (selfgenerated signal)?
-
Gomez Co. had the following transactions in the last two months of its year ended December 31.Nov. 1 Paid $1,800 cash for future newspaper advertising. 1 Paid $2,460 cash for 12 months of insurance...
-
Cherokee Incorporated is a merchandiser that provided the following information: Number of units sold Selling price per unit Variable selling expense per unit Variable administrative expense per unit...
-
Pure Plant Beauty is a sole proprietorship that has a developed a new line of skin care and makeup that uses natural and organic ingredients. The company showed the following adjusted account...
-
In man, normal color vision vs. red green colorblindness is controlled by C (dominant) and e (recessive) at an X-linked locus. a. Can a normal daughter have a color-blind father? A normal father? A...
-
You are instructed to advise the company secretary of Sleep EZ Hotels on what basis, if any, they might make a claim against IIA. Following: Introduction, Certainty, Formality, Constitution,...
-
Trahan Lumber Company hired you to help estimate its cost of capital. You obtained the following data: D 1 = $0.65; P 0 = $20.00; g = 3.50% (constant); and F = 6.00%. What is the cost of equity...
-
1. What land is particularly significant for you? It might be your current home, a previous home, a beach, bushland, a mountain etc. 2. Consider these questions in preparation for reading Alexander...
-
1. Chloe dropped a lawn chair from her apartment balcony. In an apartment below, Tracee noticed the lawn chair pass by her 3-meter tall window in 0.0464 seconds. From how high above the top of...
-
Organization Changeby W. Warner Burke: Analyze the Burke-Lutwin model displayed on p. 227 of the Burke (2019) textbook. Provide a brief explanation of how the model works in an organizational...
-
Which of the following are real motions of our "spaceshipEarth"? Select all that apply. 1:Earth moves with the Sun on an orbit around the centerof the Milky Way galaxy. 2:Earth and our solar system...
-
You are the newly appointed tax practitioner to complete Emilys tax return and have downloaded the prefill report for Emilys tax return (hint, you can read what a prefill report is here (Links to an...
-
Deborah purchases a new $30,000 car in 2012 to use exclusively in her business. If Deborah does not elect to expense or take bonus depreciation in 2012 and holds the car until it is fully...
-
Mark owns his home and has a $250,000 mortgage related to his purchase of the residence. When his daughter went to college in the fall of 2012, he borrowed $20,000 through a home equity loan on his...
-
John Williams (age 42) is a single taxpayer, and he lives at 1324 Forest Dr., Reno, NV 89501. His Social Security number is 555-94-9358. John's earnings and withholdings as the manager of a local...
-
R-12 refrigerant belongs to which group of refrigerants? (a) halo-carbon (b) azeotropes (c) inorganic (d) hydro-carbons
-
Frosting of evaporator tubes results in (a) increased heat transfer rate (b) decreased heat transfer rate (c) increased compressor pressure (d) decreased compressor pressure
-
The bank of tube at the back of a domestic refrigerator of vapour compression type is (a) evaporator (b) condenser (c) capillary (d) electric wire
Study smarter with the SolutionInn App