P6 before P4 and P5
• P5 before P3 and P2
• P4 before P2
• P1 after P3 and P4
“Pi before Pj” means that the execution of process Pi must be
completed before the execution of process Pj
Write executable code for all six processes using these
semaphores in such a way that the precedence relationships above
are always observed.
Your code must be delivered in a form such as the code below.
Simply writing down a letter or code such as P , V or wait(p1) then
signal, with no comments or further detail will not be accepted as
a solution and I will dislike your answer. Good detailed code and
code comments are essential.
P(semaphore s)
{
if (s.value == 1) {
s.value = 0;
}
else {
// add the
process to the waiting queue
q.push(P)
sleep();
}
}
V(Semaphore s)
{
if (s.q is empty) {
s.value = 1;
}
else {
// select a
process from waiting queue
Process
p=q.pop();
wakeup(p);
}
}
Pseudo code such as
P
V
Will not be accepted. You must go into detail and accurately
show your though process.
P6 before P4 and P5 • P5 before P3 and P2 • P4 before P2 • P1 after P3 and P4 “Pi before Pj” means that the execution o
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
P6 before P4 and P5 • P5 before P3 and P2 • P4 before P2 • P1 after P3 and P4 “Pi before Pj” means that the execution o
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!