Function ctru_sys::svcCreateThread

source ·
pub unsafe extern "C" fn svcCreateThread(
    thread: *mut Handle,
    entrypoint: ThreadFunc,
    arg: u32_,
    stack_top: *mut u32_,
    thread_priority: s32,
    processor_id: s32
) -> Result
Expand description

Multithreading

§*

  • Creates a new thread.

§Arguments

  • thread (direction out) - The thread handle

  • entrypoint - The function that will be called first upon thread creation

  • arg - The argument passed to entrypoint

  • stack_top - The top of the thread’s stack. Must be 0x8 bytes mem-aligned.

  • thread_priority - Low values gives the thread higher priority. For userland apps, this has to be within the range [0x18;0x3F]

    • processor_id - The id of the processor the thread should be ran on. Those are labelled starting from 0. For old 3ds it has to be <2, and for new 3DS <4.
  • Value -1 means all CPUs and -2 read from the Exheader.

  • The processor with ID 1 is the system processor.

  • To enable multi-threading on this core you need to call APT_SetAppCpuTimeLimit at least once with a non-zero value.

  • Since a thread is considered as a waitable object, you can use svcWaitSynchronization and svcWaitSynchronizationN to join with it.

  • Note: The kernel will clear the stack_top's address low 3 bits to make sure it is 0x8-bytes aligned. /