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
Which one from below is not one of the reasons of planning failures? (clo3) a)-planner is careless. b-planner spend less time in the field but more time on the desk c)-planner is not qualified d)-planner does not have sufficient time to properly plan
Answers: 3
question
Engineering, 04.07.2019 18:20
The characteristic roots of a dynamic system are: 1.7920 1.8160 i, -1.7920 1.8160 i, -0.4160 what is the order of this system? what are the settling time and damping ratio of the system?
Answers: 3
question
Engineering, 04.07.2019 19:10
Apressure vessel with an r/t 20 cannot be treated as thin walled vessel. a)-trune b)- false
Answers: 3
question
Engineering, 04.07.2019 19:20
Apure substance is a)-mixture of various chemical elements or compounds b)-substance that has a fixed chemical composition throughout c)-mixture that is homogeneous (such as air) d)-all the answers
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
Questions on the website: 13722363