Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a synchronization solution to the below scenario using semaphores only: [2Marks] Assumptions: The arcs in the chart below illustrate the processes dependencies. The CPU
Write a synchronization solution to the below scenario using semaphores only: [2Marks]
Assumptions:
- The arcs in the chart below illustrate the processes dependencies.
- The CPU can start with any process [keep in mind that always the subprocesses execute in a sequential order ex: the CPU never select to execute p2.2 before p2.1].
- The semaphores are used to ensure that the processes will execute in any sequence but within the suggested dependencies in the chart.
|
|
|
|
|
|
|
|
|
|
Code |
|
P |
3 |
.1 |
|
Code |
|
P |
2 |
. |
1 |
|
Code |
|
P1. |
1 |
|
Code |
|
P |
3 |
.2 |
|
Code |
|
P1. |
2 |
|
Answer:
//Shared variables /*Put your semaphores declaration & initialization below this line */
| ||
//Process 1 do{
Code p1.1
Code p1.2
}while(true);
[0.25 mark] | //Process 2 do{
Code
}while(true);
[0.25 mark] | //Process 3 do{
Code
Code ;
}while(true);
[0.25 mark] |
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