| Summary: | [PATCH] Semaphore: Add Atomics+WaitOnAddress Windows implementation | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Joel Linn <jl> |
| Component: | thread | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | Keywords: | target-2.0.16 |
| Version: | 2.0.13 | ||
| Hardware: | All | ||
| OS: | Windows 10 | ||
| Attachments: |
Benchmark results of Condition Variables implementation (not this patchset)
Benchmark results of Atomics+WaitOnAddr implementation (this patchset) 0001 Semaphore test: Put test into separate function. 0002 Semaphore test: Add overhead tests. 0003 Atomic test: Fix use after free 0004 Add SDL_sem implementation using Atomics and WaitOnAddress API. Add SDL_sem implementation using Atomics and WaitOnAddress API v2 0004 Add SDL_sem impl using Atomics and WaitOnAddress API v3 |
||
|
Description
Joel Linn
2020-12-10 09:54:06 UTC
Created attachment 4565 [details]
Benchmark results of Condition Variables implementation (not this patchset)
Created attachment 4566 [details]
Benchmark results of Atomics+WaitOnAddr implementation (this patchset)
Created attachment 4567 [details]
0001 Semaphore test: Put test into separate function.
Created attachment 4568 [details]
0002 Semaphore test: Add overhead tests.
Created attachment 4569 [details]
0003 Atomic test: Fix use after free
Created attachment 4570 [details]
0004 Add SDL_sem implementation using Atomics and WaitOnAddress API.
Thanks, we'll add this after 2.0.14 release. Created attachment 4577 [details]
Add SDL_sem implementation using Atomics and WaitOnAddress API v2
v2: - Fix mixed int/LONG types
- Reorder definitions
- Add missing include
Created attachment 4584 [details] 0004 Add SDL_sem impl using Atomics and WaitOnAddress API v3 v3: - Use `GetModuleHandle()` to load the API Set I wasn't sure before what the correct way to dyn load an API Set is. It is not documented by MS but I found a discussion about it on the MS C++ STL issue tracker. https://github.com/microsoft/STL/pull/593#issuecomment-655799859 Two things need to be satisfied to be able to legally load an API Set dynamically using `GetModuleHandle()`: - It needs to be legal to call the function on an API Set in the first place. It's nowhere documented explicitly but a senior from MS confirmed it's legal and they do it as well in their STL implementation (see github link, they discussed it in length). - The module that implements the API set (currently KernelBase.dll but that is an implementation detail of W10 Desktop and may change.) needs to be loaded already. In our case this is guaranteed because we already link to other functions of that API Set statically (like WaitForSingleObject, see https://docs.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-core-synch-l1-2-0dll for a list). |