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 synchronization primitives on Windows #2628

Closed
4 tasks done
RalfJung opened this issue Oct 28, 2022 · 4 comments · Fixed by #2638
Closed
4 tasks done

Support synchronization primitives on Windows #2628

RalfJung opened this issue Oct 28, 2022 · 4 comments · Fixed by #2638
Labels
A-shims Area: This affects the external function shims A-windows Area: affects only Windows targets E-good-first-issue A good way to start contributing, mentoring is available

Comments

@RalfJung
Copy link
Member

RalfJung commented Oct 28, 2022

Thanks to @drmeepster we now do support basic concurrency and atomics on Windows (#2231). However, we do not support all of the standard library concurrency primitives. Based on my testing:

  • Mutex
  • RwLock
  • Condvar
  • thread parking

The fact that we don't support thread parking (which is needed by std::sync::mpsc) unfortunately blocks rust-lang/rust#103681.

@RalfJung
Copy link
Member Author

@drmeepster if I recall, you actually had a first implementation of at least thread parking. Is that code still available somewhere?

@RalfJung
Copy link
Member Author

Looks like the code still exists here, in particular in 2cd61e6.

@RalfJung RalfJung added A-shims Area: This affects the external function shims A-windows Area: affects only Windows targets E-medium labels Oct 28, 2022
bors added a commit that referenced this issue Oct 28, 2022
Implement thread parking for Windows

Cc #2628

Based on code by `@DrMeepster.` However I adjusted `WakeByAddressSingle`: I don't think the futex value is compared *again* after the thread is woken up. I see nothing in the Windows docs indicating such a comparison, and the Linux futex does not behave like that either. So we only check the value before sleeping, same as on Linux.
RalfJung pushed a commit to RalfJung/rust that referenced this issue Oct 29, 2022
Implement thread parking for Windows

Cc rust-lang/miri#2628

Based on code by `@DrMeepster.` However I adjusted `WakeByAddressSingle`: I don't think the futex value is compared *again* after the thread is woken up. I see nothing in the Windows docs indicating such a comparison, and the Linux futex does not behave like that either. So we only check the value before sleeping, same as on Linux.
@RalfJung
Copy link
Member Author

Thread parking is implemented now, Condvars are still missing.

@RalfJung RalfJung added E-good-first-issue A good way to start contributing, mentoring is available and removed E-medium labels Oct 29, 2022
@beepster4096
Copy link
Contributor

Opened #2638 for condvars

@bors bors closed this as completed in 32c90ff Nov 6, 2022
RalfJung pushed a commit to RalfJung/miri that referenced this issue Nov 15, 2022
Implement condvars for Windows

Adds 3 shims for Windows: `SleepConditionVariableSRW`, `WakeConditionVariable`, `WakeAllConditionVariable` to add support for condvars (which fixes rust-lang#2628).

Salvaged from what was removed from rust-lang#2231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-shims Area: This affects the external function shims A-windows Area: affects only Windows targets E-good-first-issue A good way to start contributing, mentoring is available
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants