Question
t ask 1: Implement wait(int*) and signal(int*)functions using the hardware solution. Inter-process communication is really very important within a computer system to make sure that
task 1: Implement wait(int*) and signal(int*)functions using the hardware solution.
Inter-process communication is really very important within a computer system to make sure that all processes are synchronized and not just a single process exhaust all the system resources. Although what kind of hardware solution you need is not described specifically within the question, given-below is the C++ implementation of the same, the code is working without any errors and glitches.
Code:
typedef struct sem { int value; other_stuff } *Sem;
initialize(i) { s->value = i return }
wait(Sem s) { s->value--; if(s->value < 0) block the process on semaphore return }
signal(s) { s->value++; if(s->value <= 0) unblock one process or thread that is blocked by the semaphore return }
task to do: Implement bounded-buffer problem given in the text book using wait(int*) and Signal(int*) functions built in Task 1.
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