Question
Program has to be in C++ Q) Create a system with parallel processes that will use a ring buffer. The parent process must create the
Program has to be in C++
Q) Create a system with parallel processes that will use a ring buffer. The "parent" process must create the semaphore set and segment and start its child, then it can back off and wait for the others to finish. Create a process that reads characters from the keyboard and writes them to the ring buffer, you must create a process that generates text and places it on the ring buffer, and you must create a process that reads from the ring buffer and writes to the screen. All necessary resources must be synchronized.
code below is an half written code, where i need to impliment rest, whats is asked in the question above.
#include
template
bool Get(T* object) { if (peek(object)) { mHead = (mHead + 1) % mObjects.size(); return true } return false; } bool Peek(T* object) const { if (!IsEmpty()) { *object = mObjects[mHead]; return true; } return false; } bool IsEmpty() const { return mHead == mTail; }
bool IsFull() const { return ((mTail + 1) % mObjects.size()) == mHead;
}
size_t() const { return (mTail < mHead) ? (mTail + mObjects.size() - mHead): (mTail - mHead); }
private: std::vector
int main() {
RingBuffer
char tmp_char; std::cout << "Could peek: " <
std::cout <<"Size: " <
std::cout <<"Coud get: " << budder.Get(&tmp_char) << std::endl;
std::cout << "Value feathced: " << tmp_char << std::endl; std::cout << "Size: " <
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started