With user-level threads, can a low-priority thread be preempted to allow a high-priority thread run ?
My reasoning to this question in Modern Operating Systems was:
A user level thread is handled by the user level process. The user process can kick its threads on or off the CPU during its allotted time slice (quantum). However, the kernel cannot see the user level thread: it just knows that a particular user process is running in its allotted time slice.
When a thread enters its critical section, it requires a shared resource handled by the system. Thus, a system call is made.
However, when a thread makes a system call, all the other threads in the parent process are blocked. This means that a sibling thread cannot preempt the blocking thread.
Therefore, although preemption can happen to a user level thread, priority inversion cannot.
Edit: After learning a bit more, I found out that preemption at user-level threads is dependent on thread model (i.e. mapping of user level threads to kernel level threads) and their implementation. Will update once further info is acquired.
Based on my reading of the MOS by AT, I realised that the solution says so because preemption requires timer interrupts (The other way is yielding, which would never happen during critical section execution) and there are no timer interrupts at user level threads (at least it has not been discussed in the book). This doesn't mean that preemption cannot be implemented in user level threads, as discussed here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With