PinCRT
Functions
Threads

Functions

OS_RETURN_CODE OS_CreateThread (VOID(*ThreadMainFunction)(VOID *), VOID *ThreadParam, VOID *stackBottom, ADDRINT stackSize, NATIVE_TID *td)
 
OS_RETURN_CODE OS_ExitThread (NATIVE_TID td)
 
OS_RETURN_CODE OS_ThreadExitAndClear (void *stackAddr, ADDRINT stackSize, INT32 *dwordToReset)
 
OS_RETURN_CODE OS_SuspendThread (NATIVE_TID td)
 
OS_RETURN_CODE OS_ResumeThread (NATIVE_TID td)
 
OS_RETURN_CODE OS_Sleep (INT interval)
 
OS_RETURN_CODE OS_GetTid (NATIVE_TID *id)
 
OS_RETURN_CODE OS_Yield (void)
 
OS_RETURN_CODE OS_RaiseException (NATIVE_TID td, UINT32 code)
 

Detailed Description

Contains thread-related os apis

Function Documentation

◆ OS_CreateThread()

OS_RETURN_CODE OS_CreateThread ( VOID(*)(VOID *)  ThreadMainFunction,
VOID *  ThreadParam,
VOID *  stackBottom,
ADDRINT  stackSize,
NATIVE_TID td 
)

Create a new thread in the current process.

Parameters
[in]ThreadMainFunctionThread start address
[in]ThreadParamThread optional parameter
[in]stackBottomThe base address of the thread's stack. This argument can be NULL. In that case this function will allocate the stack according to the stackSize argument.
[in]stackSizeThe size of the thread's stack.
[out]tdThe descriptor of newly created thread.
Return values
OS_RETURN_CODE_NO_ERRORIf the operation succeeded
OS_RETURN_CODE_THREAD_CREATE_FAILEDIf the operation Failed
Returns
Operation status code.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_ExitThread()

OS_RETURN_CODE OS_ExitThread ( NATIVE_TID  td)

Causes a running thread to exit.

Parameters
[in]tdThread descriptor
Return values
OS_RETURN_CODE_NO_ERRORIf the operation succeeded
OS_RETURN_CODE_THREAD_EXIT_FAILEDIf the operation Failed
Returns
Operation status code.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_GetTid()

OS_RETURN_CODE OS_GetTid ( NATIVE_TID id)

Retrieves the current thread's handle.

Parameters
[out]idAddress of handle container variable
Return values
OS_RETURN_CODE_NO_ERRORIf the operation succeeded
OS_RETURN_CODE_THREAD_QUERY_FAILEDIf the operation Failed
Returns
Operation status code.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_RaiseException()

OS_RETURN_CODE OS_RaiseException ( NATIVE_TID  td,
UINT32  code 
)

Raise an exception.

Parameters
[in]tdThread descriptor
[in]codeException type
Return values
OS_RETURN_CODE_NO_ERRORIf the operation succeeded
OS_RETURN_CODE_THREAD_SLEEP_FAILEDIf the operation Failed
Returns
Operation status code.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_ResumeThread()

OS_RETURN_CODE OS_ResumeThread ( NATIVE_TID  td)

Resumes running thread.

Parameters
[in]tdThread descriptor
Return values
OS_RETURN_CODE_NO_ERRORIf the operation succeeded
OS_RETURN_CODE_THREAD_RESUME_FAILEDIf the operation Failed
Returns
Operation status code.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_Sleep()

OS_RETURN_CODE OS_Sleep ( INT  interval)

Sends thread to sleep.

Parameters
[in]intervalInterval to sleep in milli-seconds.
Return values
OS_RETURN_CODE_NO_ERRORIf the operation succeeded
OS_RETURN_CODE_THREAD_SLEEP_FAILEDIf the operation Failed
Returns
Operation status code.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_SuspendThread()

OS_RETURN_CODE OS_SuspendThread ( NATIVE_TID  td)

Suspends a running thread.

Parameters
[in]tdThread descriptor
Return values
OS_RETURN_CODE_NO_ERRORIf the operation succeeded
OS_RETURN_CODE_THREAD_SUSPEND_FAILEDIf the operation Failed
Returns
Operation status code.
Availability:
O/S: Windows, Linux & macOS*
CPU: All

◆ OS_ThreadExitAndClear()

OS_RETURN_CODE OS_ThreadExitAndClear ( void *  stackAddr,
ADDRINT  stackSize,
INT32 *  dwordToReset 
)

This function clears a word and then exits the calling thread. It guaranteess that it will use only register state (no memory) once word is cleared.

Parameters
[in]codeThe thread exit code as passed from the caller
[out]dwordToResetThis memory location is cleared (set to zero).
Return values
OS_RETURN_CODE_THREAD_EXIT_FAILEDIf the operation Failed
Returns
Operation status code.
Availability:
O/S: Linux & macOS*
CPU: All

◆ OS_Yield()

OS_RETURN_CODE OS_Yield ( void  )

Pre-empts the thread specified by the running thread.

Return values
OS_RETURN_CODE_NO_ERRORIf the operation succeeded
OS_RETURN_CODE_THREAD_SLEEP_FAILEDIf the operation Failed
Returns
Operation status code.
Availability:
O/S: Windows, Linux & macOS*
CPU: All