In: Computer Science
Assume you have two processes, P1 and P2. P1 has a high priority, P2 has a low priority. P1 and P2 have one shared semaphore (i.e., they both carry out waits and posts on the same semaphore). The processes can be interleaved in any arbitrary order (e.g. P2 could be started before P1).
i. Explain the problem with priority inversion
Briefly explain whether the processes could deadlock when:
ii. both processes run on a Linux system as time sharing tasks
iii. both processes run on a Windows 7 system as variable tasks
iv. both processes run on a Windows 7 system as real-time tasks.
i)
Priority inversion problem would occur in the following case:-
Suppose initially the process P2 comes and starts executing the critical section which is residing inside the semaphores and now the higher priority process P1 comes but is not able to enter the critical section as we are using semaphores and also P2 is not able to execute since the CPU gets buzy with process P1 .So,in this case CPU is with process P1 and semaphores are with P2 and hence these processes enter into a deadlock.
ii)
No deadlock would occur in this case as the processes are being executed in time sharing mode so the 2 processes would not interfere with each other.
ii) No deadlock would occur as in variable task so the system would make the other wait process in different location so that it would not interfere with the currently running processses,so deadlock would not occur.
iv)Yes,in this case deadlock can occur as the both the processes would be real time so they would be wanting to finish their work as early as possible so in this case deadlock would be possible as one process would not wait for the other process to finish first.