please i need help Consider the below code of process P1 and P2, where S1 and S2
ID: 3593407 • Letter: P
Question
please i need help
Explanation / Answer
Q1.) This code only ensures that A1 and A2 run Before B1 and B2. A1 and A2 can run in any order as os can give any of the processes to go first and P1 and P2 are made dependent on each other for running B1 and B2 using semaphores.Similarly, B1 and B2 can also run in any order.
Q2.) We can define S array with 1 to n index and set its value to 0. A function all_up() which Return True if all elements in the array are 1 else False.This will ensure that all Ai are run before Bi and there is no order of execution.
Pi {
Ai();
UP(S[i]);
while(!(all_up(S)));
Bi();
}
If you have any confusion or do not agree with solution please comment.I am available to help.Thank you.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.