subject
Engineering, 16.04.2020 21:52 19King73

The goal of this programming assignment is to give you a basic introduction to the students IPC mechanisms and synchronization using semaphores. You need to write and run C programs (as processes on your Linux machine), and monitor their behavior. Consider the following problem: A program is to be written to print all numbers between 1 and 1000 (inclusive) that are not (evenly) divisible by either 2 or 3. This problem is to be solved using three processes (PO, P1, P2) and two one-integer buffers (BO and B1) as follows:

PO is to generate the integers from 1 to 1000, and place them in BO one at a time. After placing 1000 in the buffer, PO places the sentinel 0 in the buffer, and terminates.
P1 is to read successive integers from BO. If a value is not divisible by 2, the lue is placed in B1. If the value is positive and divisible by 2, it is ignored. If the value is 0, 0 is placed in B1, and P1 terminates.
P2 is to read successive integers from B1. If a value is not divisible by 3, it is printed. If the value is positive and divisible by 3, it is ignored. If the value is 0, P2 terminates.

Write a program to implement PO, P1, and P2 as separate processes and BO and B1 as separate pieces of shared memory {each the size of just one integer}. Use semaphores to coordinate processing. Access to BO should be independent of access to B1; for example, PO could be writing into BO while either P1 was writing into B1 or P2 was reading.

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 14:10
The y form of iron is known as: a) ferrite b) cementite c) perlite d) austenite
Answers: 3
question
Engineering, 03.07.2019 19:30
When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested? a. parallel b. control c. series d. line
Answers: 3
question
Engineering, 04.07.2019 18:10
Water at the rate of 1 kg/s is forced through a tube with a 2.5 cm inner diameter. the inlet water temperature is 15°c, and the outlet water temperature is 50°c. the tube wall temperature is 14°c higher than the local water temperature all along the length of the tube. what is the length of the tube?
Answers: 3
question
Engineering, 04.07.2019 18:10
An air compression refrigeration system is to have an air pressure of 100 psia in the brine tank and an allowable air temperature increase of 60°f for standard vapor compression cycle temperatures of 77 f entering the expansion cylinder and 14 f entering the compression cylinder, calculate the coefficient of performance a. 2.5 b 3.3 c. 4.0 d. 5.0
Answers: 3
You know the right answer?
The goal of this programming assignment is to give you a basic introduction to the students IPC mech...
Questions
question
Mathematics, 18.10.2019 04:10
question
Mathematics, 18.10.2019 04:10
Questions on the website: 13722360