30.3k views
3 votes
Consider two processes PI & P2 on a system. memory address space. Assume Peterson's solution is used for providing mutual exclusive access to the PI has high priority over P2. Both P1 & P2 share a single shared memory space. Justify your answer. then P2. Modify the pseudo code of Peterson's solution to include ordering. The request for the shared resource by P1 and P2 should follow an order as PI then P2. Modify the pseudo code of Peterson's solution to include ordering. Justify your answer.

User DLR
by
8.3k points

1 Answer

1 vote

Final answer:

Peterson's solution can be modified to include ordering by introducing a new variable 'order' and updating its value according to the priority of the processes. This ensures that P1 always has higher priority than P2.

Step-by-step explanation:

Peterson's solution is a classic algorithm used to provide mutual exclusion in concurrent processes. It ensures that only one process can access a shared resource at a time. To modify the solution to include ordering, we can introduce an additional variable to keep track of the order of request.

In the modified pseudo code, we can define a new variable 'order' and update its value when a process requests the shared resource. P1 will set 'order' to 1, indicating that it wants to access the resource before P2. P2 will set 'order' to 2, indicating that it wants to access the resource after P1.

When a process wants to enter the critical section, it will first check if the other process has a lower 'order' value. If so, it will wait until the other process has finished. This ensures that P1 always has priority over P2.

User Murrekatt
by
8.4k points