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, 04.07.2019 18:10
The temperature of air decreases as it is compressed by an adiabatic compressor. a)- true b)- false
Answers: 2
question
Engineering, 04.07.2019 18:10
Aloaded platform of total mass 500 kg is supported by a dashpot and by a set of springs of effective stiffness 72 kn/m. it is observed that when the platform is depressed through a distance x = 12.5 cm below its equilibrium position and then released without any initial velocity; it reaches its equilibrium position in the shortest possible time without overshoot. find the position and velocity of the loaded platform 0.10 sec. after its release. if a further load of 400 kg is added to the platform, find, i) the frequency of damped vibrations, and i) the amplitude of vibration after 2 complete oscillations, given that the initial amplitude is 15 cm.
Answers: 1
question
Engineering, 04.07.2019 18:10
Afour cylinder four-stroke in-line engine has a stroke of 160mm, connecting rod length of 150mm, a reciprocating mass of 3kg and its firing order is 1-3-4-2. the spacing between cylinders is 100mm. i. show that the engine is in balance with regard to the primary inertia forces and primary 3. a and secondary inertia couples. li determine the out of balance secondary inertia force ii. propose ways of balancing this out of balance force and discuss the challenges that will arise
Answers: 3
question
Engineering, 04.07.2019 18:20
Inspection for bearing condition will include: (clo4) a)-color b)-smell c)-size d)-none of the above
Answers: 1
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, 03.04.2020 07:57
question
Chemistry, 03.04.2020 07:57
question
Social Studies, 03.04.2020 07:57
Questions on the website: 13722361