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
Afluid flows with a velocity field given by v=(x/t)i.. determine the local and convective accelerations when x=3 and t=1.
Answers: 2
question
Engineering, 04.07.2019 18:10
The thermal expansion or contraction of a given metal is a function of the f a)-density b)-initial temperature c)- temperature difference d)- linear coefficient of thermal expansion e)- final temperature f)- original length
Answers: 2
question
Engineering, 04.07.2019 18:10
An ideal otto cycle with air as the working fluid has a compression ratio of 8. the minimum and maximum temperatures in the cycle are 300 k and 1340 k. use constant specific heats at room temperature to determine (a) the amount of heat transferred to the air during the heat- addition kj/kg, (b) the thermal efficiency, and (c) the thermal efficiency of a carnot cycle ope limits. process, in rating between the same temperature
Answers: 2
question
Engineering, 04.07.2019 18:20
A2-m rigid tank initially contains saturated water vapor at 100 kpa. the tank is connected to a supply line through a valve. steam is flowing in the supply line at 600 kpa and 300 c. the valve is opened, and steam is allowed to enter the tank until the pressure in the tank reaches the line pressure, at which point the valve is closed. a thermometer placed in the tank indicates that the temperature at the final state is 200°c. determine (a) the mass of steam that has entered the tank (b) the amount of heat transfer.
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
History, 28.09.2021 16:50
Questions on the website: 13722361