Hi,
I can try to describe one scenario, the scenario I am working on now. It is more of a 'helicopter view' than code would be. If necessary, I can write some code also.
I am working on soft real-time Linux network measurement application that should scale from low-end 1-core machines up to future multicore machines (32 cores or more, both NUMA and SMP).
For handling many UDP streams, low- and high-bandwidh, we divide workload so each worker thread handles its subset of the streams. Further, we separate sender and receiver worker threads. On multicore machines, we will use one worker thread per CPU core available, but obviously not on 1-core machines.
For high performance, the workers must have Linux realtime priority, typically SCHED_FIFO or SCHED_RR. The other threads in the application (main thread, statistics collector threads) are low-prio SCHED_OTHER threads.
Now, the problem: The low and high-prio threads share mutex locks. Consider a 1-core machine and this scenario, with 1 high-prio sender worker, 1 high-prio receiver worker, and a low-prio statistics thread.
1. Statistics thread goes to work to process statistics, acquires stats lock L.
2. Receiver worker wants to push stats, tries to acquire L and blocks.
3. Sender worker gets scheduled in since it is high-prio and is not blocking on L.
4. Stats thread cannot run, but holds L. This means that receiver worker (high-prio) cannot run for a long time, if sender worker runs for a long time. Receiver socket buffers in kernel overflow, and kernel drops packets.
The scenario above is not dependency inversion, but similar to it. If L had prio ceiling or prio inheritance configured, the stats thread would temporarily be raised to high-prio, and could do its work and promptly release the lock.
Let me know if anything is unclear.