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

Implement macOS dispatch semaphores #2589

Open
RalfJung opened this issue Oct 8, 2022 · 2 comments
Open

Implement macOS dispatch semaphores #2589

RalfJung opened this issue Oct 8, 2022 · 2 comments
Labels
A-concurrency Area: affects our concurrency (multi-thread) support A-mac Area: Affects only macOS targets A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@RalfJung
Copy link
Member

RalfJung commented Oct 8, 2022

rust-lang/rust#102773 has started using macOS dispatch semaphores for thread parking on macOS. We should implement those APIs in Miri. (Right now a cfg(miri) makes miri use a pthread-based fallback implementation.)

These seem to be the API docs.

@RalfJung RalfJung added A-shims Area: This affects the external function shims A-mac Area: Affects only macOS targets labels Oct 8, 2022
@thomcc
Copy link
Member

thomcc commented Oct 8, 2022

Yes, those are the docs. Feel free to ping me if you have questions.

Note that its lifetime is managed by dispatch_retain/dispatch_release calls, which manage an atomic reference count. We only use dispatch_release in std patch (since the object returned by dispatch_create has a retain count of 1 initially), and I don't see a reason in the near term we'd use dispatch_retain for anything, but I'd advise against implementing this in a way that adding the refcount later would require major hacks or something, not that that seems likely.

@RalfJung
Copy link
Member Author

rust-lang/rust#122408 may switch the macOS primitives to yet another OS API, so I am not sure if it would currently be worth it to implement dispatch semaphores.

@RalfJung RalfJung added the C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement label Apr 18, 2024
@RalfJung RalfJung added E-good-second-issue A good issue to pick up if you've already seen some parts of Miri, mentoring is available A-concurrency Area: affects our concurrency (multi-thread) support and removed E-good-second-issue A good issue to pick up if you've already seen some parts of Miri, mentoring is available labels May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: affects our concurrency (multi-thread) support A-mac Area: Affects only macOS targets A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

No branches or pull requests

2 participants