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
Fluids at rest possess no flow energy. a)- true b)- false
Answers: 3
question
Engineering, 04.07.2019 18:10
Which of the following components of a pid controlled accumulates the error over time and responds to system error after the error has been accumulated? a)- proportional b)- derivative c)- integral d)- on/off.
Answers: 2
question
Engineering, 04.07.2019 18:10
Compute the pressure drop of 30°c air flowing with a mean velocity of 8 m/s in a circular sheet-metal duct 300 mm in diameter and 15 m long. use a friction factor, f 0.02, and pair = 1.1644 kg/m a. 37.26 pa b. 25.27 pa n c. 29.34 pa d. 30.52 pa
Answers: 1
question
Engineering, 04.07.2019 18:20
Find the kinematic pressure of 160kpa. for air, r-287 j/ kg k. and hair al viscosity of air at a temperature of 50°c and an absolute (10 points) (b) find the dynamic viscosity of air at 110 °c. sutherland constant for air is 111k
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, 02.12.2021 02:10
question
Computers and Technology, 02.12.2021 02:10
question
Mathematics, 02.12.2021 02:10
question
Health, 02.12.2021 02:10
question
English, 02.12.2021 02:10