Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support priority inheritance #205

Open
comex opened this issue Jan 9, 2020 · 1 comment
Open

Support priority inheritance #205

comex opened this issue Jan 9, 2020 · 1 comment

Comments

@comex
Copy link

comex commented Jan 9, 2020

On macOS and iOS, as of last year or so, many kernel synchronization mechanisms support priority inheritance out of the box. (For a list of things that support it, see this header and scroll down a bit.) When using one of those mechanisms, a waiting thread knows which thread it's waiting for, and if the waiter has higher priority than the waitee, the kernel temporarily boosts the waitee's priority to match.

Priority inheritance is clearly useful across processes. One might think that it's not very useful within a single process, since it's rare for threads in the same process to be set at different priorities. But even if they're set at the same priority, they can have different effective priorities if one of them has been boosted by priority inheritance from another process. If that thread then tries to lock a mutex held by another thread, it should be able to pass on its boost to the latter thread. For this reason, the list of mechanisms supporting priority inheritance includes pthread mutexes (as well as ulocks, another kind of userland mutex).

As far as I can tell, parking_lot currently doesn't support priority inheritance on any platform; park has no way of notifying the kernel which thread it's waiting for. It would be good to fix this, though it might require substantial API changes.

@Amanieu
Copy link
Owner

Amanieu commented Jan 9, 2020

I think that this is outside the scope of parking_lot. If you need priority inheritance then you should be using an OS mutex that supports it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants