-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8781cda
commit e889ff1
Showing
3 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
###### (This is the documentation for SDL3, which is under heavy development and the API is changing! [SDL2](https://wiki.libsdl.org/SDL2/) is the current stable version!) | ||
# SDL_CPUPauseInstruction | ||
|
||
A macro to insert a CPU-specific "pause" instruction into the program. | ||
|
||
## Header File | ||
|
||
Defined in [<SDL3/SDL_atomic.h>](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_atomic.h) | ||
|
||
## Syntax | ||
|
||
```c | ||
#define SDL_CPUPauseInstruction() DoACPUPauseInACompilerAndArchitectureSpecificWay | ||
``` | ||
## Remarks | ||
This can be useful in busy-wait loops, as it serves as a hint to the CPU as | ||
to the program's intent; some CPUs can use this to do more efficient | ||
processing. On some platforms, this doesn't do anything, so using this | ||
macro might just be a harmless no-op. | ||
Note that if you are busy-waiting, there are often more-efficient | ||
approaches with other synchronization primitives: mutexes, semaphores, | ||
condition variables, etc. | ||
## Thread Safety | ||
This macro is safe to use from any thread. | ||
## Version | ||
This macro is available since SDL 3.0.0. | ||
---- | ||
[CategoryAPI](CategoryAPI), [CategoryAPIMacro](CategoryAPIMacro) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
###### (This is the documentation for SDL3, which is under heavy development and the API is changing! [SDL2](https://wiki.libsdl.org/SDL2/) is the current stable version!) | ||
# SDL_SpinLock | ||
|
||
An atomic spinlock. | ||
|
||
## Header File | ||
|
||
Defined in [<SDL3/SDL_atomic.h>](https://github.com/libsdl-org/SDL/blob/main/include/SDL3/SDL_atomic.h) | ||
|
||
## Syntax | ||
|
||
```c | ||
typedef int SDL_SpinLock; | ||
``` | ||
|
||
## Remarks | ||
|
||
The atomic locks are efficient spinlocks using CPU instructions, but are | ||
vulnerable to starvation and can spin forever if a thread holding a lock | ||
has been terminated. For this reason you should minimize the code executed | ||
inside an atomic lock and never do expensive things like API or system | ||
calls while holding them. | ||
|
||
They are also vulnerable to starvation if the thread holding the lock is | ||
lower priority than other threads and doesn't get scheduled. In general you | ||
should use mutexes instead, since they have better performance and | ||
contention behavior. | ||
|
||
The atomic locks are not safe to lock recursively. | ||
|
||
Porting Note: The spin lock functions and type are required and can not be | ||
emulated because they are used in the atomic emulation code. | ||
|
||
---- | ||
[CategoryAPI](CategoryAPI), [CategoryAPIDatatype](CategoryAPIDatatype) | ||
|