Multi-threading support.
More...
Go to the source code of this file.
Multi-threading support.
- Author
- plutoo
- Copyright
- libnx Authors
◆ threadClose()
Frees up resources associated with a thread.
- Parameters
-
t | Thread information structure. |
- Returns
- Result code.
◆ threadCreate()
Result threadCreate |
( |
Thread * |
t, |
|
|
ThreadFunc |
entry, |
|
|
void * |
arg, |
|
|
void * |
stack_mem, |
|
|
size_t |
stack_sz, |
|
|
int |
prio, |
|
|
int |
cpuid |
|
) |
| |
Creates a thread.
- Parameters
-
t | Thread information structure which will be filled in. |
entry | Entrypoint of the thread. |
arg | Argument to pass to the entrypoint. |
stack_mem | Memory to use as backing for stack/tls/reent. Must be page-aligned. NULL argument means to allocate new memory. |
stack_sz | If stack_mem is NULL, size to use for stack. If stack_mem is non-NULL, size to use for stack + reent + tls (must be page-aligned). |
prio | Thread priority (0x00~0x3F); 0x2C is the usual priority of the main thread, 0x3B is a special priority on cores 0..2 that enables preemptive multithreading (0x3F on core 3). |
cpuid | ID of the core on which to create the thread (0~3); or -2 to use the default core for the current process. |
- Returns
- Result code.
◆ threadDumpContext()
Dumps the registers of a thread paused by threadPause (register groups: all).
- Parameters
-
[out] | ctx | Output thread context (register dump). |
| t | Thread information structure. |
- Returns
- Result code.
- Warning
- Official kernel will not dump x0..x18 if the thread is currently executing a system call, and prior to 6.0.0 doesn't dump TPIDR_EL0.
◆ threadGetCurHandle()
Handle threadGetCurHandle |
( |
void |
| ) |
|
Gets the raw handle to the current thread.
- Returns
- The current thread's handle.
◆ threadGetSelf()
Thread* threadGetSelf |
( |
void |
| ) |
|
Gets a pointer to the current thread structure.
- Returns
- Thread information structure.
◆ threadPause()
Pauses the execution of a thread.
- Parameters
-
t | Thread information structure. |
- Returns
- Result code.
◆ threadResume()
Resumes the execution of a thread, after having been paused.
- Parameters
-
t | Thread information structure. |
- Returns
- Result code.
◆ threadStart()
Starts the execution of a thread.
- Parameters
-
t | Thread information structure. |
- Returns
- Result code.
◆ threadTlsAlloc()
s32 threadTlsAlloc |
( |
void(*)(void *) |
destructor | ) |
|
Allocates a TLS slot.
- Parameters
-
destructor | Function to run automatically when a thread exits. |
- Returns
- TLS slot ID on success, or a negative value on failure.
◆ threadTlsFree()
void threadTlsFree |
( |
s32 |
slot_id | ) |
|
Frees a TLS slot.
- Parameters
-
◆ threadTlsGet()
void* threadTlsGet |
( |
s32 |
slot_id | ) |
|
Retrieves the value stored in a TLS slot.
- Parameters
-
- Returns
- Value.
◆ threadTlsSet()
void threadTlsSet |
( |
s32 |
slot_id, |
|
|
void * |
value |
|
) |
| |
Stores the specified value into a TLS slot.
- Parameters
-
slot_id | TLS slot ID. |
value | Value. |
◆ threadWaitForExit()
Waits for a thread to finish executing.
- Parameters
-
t | Thread information structure. |
- Returns
- Result code.