Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have to create a program in c++ dealing with semaphores. I attached the instructions below along with my progress. I am stuck on how

I have to create a program in c++ dealing with semaphores.

I attached the instructions below along with my progress. I am stuck on how to make two child processes work (1 on U and 1 on V) while i make the other two processes wait for their turn.

My next point of confusion, is how do i manage the child processes? it says they should work on U and V in FIFO order. How can i make them do that? Would i be able to use a queue? if so how?

image text in transcribed

Semaphore Class that was given and should not be modified:

image text in transcribed

image text in transcribed

What i have done so far: (I know its not much)

image text in transcribedimage text in transcribedimage text in transcribed

CECS 326: Project 4 Objectives: Interprocess communication with semaphores and shared memory. Implement a system to guarantee the child processes are resumed in accordance to their order in a FIFO queue. That is, a FIFO queue is used to determine the sequence that child processes will be resumed The child at the front of the queue is next to be resumed. For simplicity, a child will repeatedly generate a random integer and test if it's a factor of some integer X (see below), until it generates a random integer less than 100 or is divisible by X, then it yields its turn to the next child process. That is, it enqueues itself for its next turn, resumes the next child in the queue and halts. To make the programming more interesting: Four child processes will be spawned to compute whether some integer is a factor of: U-827395609 or V-962094883. One of the child processes works concurrently on integer U, as another child works on integer V, while the other 2 child processes wait for their turn. No two child processes can operate on the same integer. The parent process (oldest) prompts for exit command: "!wq". All processes will terminate on this input string. (It's not important what each software outputs on the console.) When a child is resumed & continues its execution, it needs to determine which of the 2 integers U or V to work on. Again, no two child processes can operate on the same integer. There are different ways to do this. You have permission to use SEMAPHORE class for this assignment. Demo your software and submit hard copy of your source code for grading. Along with a software description, include a small paragraph to explain whether or not your solution exhibits starvation or deadlock. CECS 326: Project 4 Objectives: Interprocess communication with semaphores and shared memory. Implement a system to guarantee the child processes are resumed in accordance to their order in a FIFO queue. That is, a FIFO queue is used to determine the sequence that child processes will be resumed The child at the front of the queue is next to be resumed. For simplicity, a child will repeatedly generate a random integer and test if it's a factor of some integer X (see below), until it generates a random integer less than 100 or is divisible by X, then it yields its turn to the next child process. That is, it enqueues itself for its next turn, resumes the next child in the queue and halts. To make the programming more interesting: Four child processes will be spawned to compute whether some integer is a factor of: U-827395609 or V-962094883. One of the child processes works concurrently on integer U, as another child works on integer V, while the other 2 child processes wait for their turn. No two child processes can operate on the same integer. The parent process (oldest) prompts for exit command: "!wq". All processes will terminate on this input string. (It's not important what each software outputs on the console.) When a child is resumed & continues its execution, it needs to determine which of the 2 integers U or V to work on. Again, no two child processes can operate on the same integer. There are different ways to do this. You have permission to use SEMAPHORE class for this assignment. Demo your software and submit hard copy of your source code for grading. Along with a software description, include a small paragraph to explain whether or not your solution exhibits starvation or deadlock

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

What is the difference between a concept and a construct?

Answered: 1 week ago