# Thread Manager Library

## Detailed Description

Library imports for the kernel threading library.

## Data Structures

struct | SceKernelSysClock
| 64-bit system clock type. More...
struct | SceKernelThreadOptParam
| Additional options used when creating threads. More...
struct | SceKernelThreadInfo
| Structure to hold the status information for a thread. More...
struct | SceKernelThreadRunStatus
| Statistics about a running thread. More...
struct | SceKernelSemaOptParam
| Additional options used when creating semaphores. More...
struct | SceKernelSemaInfo
| Current state of a semaphore. More...
struct | _SceKernelCallbackInfo
| Structure to hold the status information for a callback. More...
struct | _SceKernelSystemStatus
| Structure to contain the system status returned by sceKernelReferSystemStatus. More...
struct | _SceKernelEventFlagInfo
| Structure to hold the event flag information. More...
struct | SceKernelMbxOptParam
| Additional options used when creating messageboxes. More...
struct | SceKernelMbxInfo
| Current state of a messagebox. More...

## Defines

#define | THREAD_ATTR_VFPU PSP_THREAD_ATTR_VFPU
#define | THREAD_ATTR_USER PSP_THREAD_ATTR_USER

## Typedefs

typedef SceKernelSysClock | SceKernelSysClock
| 64-bit system clock type.
typedef int(* | SceKernelThreadEntry )(SceSize args, void *argp)
typedef SceKernelThreadOptParam | SceKernelThreadOptParam
| Additional options used when creating threads.
typedef SceKernelThreadInfo | SceKernelThreadInfo
| Structure to hold the status information for a thread.
typedef SceKernelThreadRunStatus | SceKernelThreadRunStatus
| Statistics about a running thread.
typedef SceKernelSemaOptParam | SceKernelSemaOptParam
| Additional options used when creating semaphores.
typedef SceKernelSemaInfo | SceKernelSemaInfo
| Current state of a semaphore.
typedef int(* | SceKernelCallbackFunction )(int arg1, int arg2, void *arg)
| Callback function prototype.
typedef _SceKernelCallbackInfo | SceKernelCallbackInfo
typedef _SceKernelSystemStatus | SceKernelSystemStatus
typedef _SceKernelEventFlagInfo | SceKernelEventFlagInfo
typedef SceKernelMbxOptParam | SceKernelMbxOptParam
| Additional options used when creating messageboxes.
typedef SceKernelMbxInfo | SceKernelMbxInfo
| Current state of a messagebox.

## Enumerations

enum | PspThreadAttributes { PSP_THREAD_ATTR_VFPU = 0x00004000, PSP_THREAD_ATTR_USER = 0x80000000, PSP_THREAD_ATTR_USBWLAN = 0xa0000000, PSP_THREAD_ATTR_VSH = 0xc0000000, PSP_THREAD_ATTR_SCRATCH_SRAM = 0x00008000, PSP_THREAD_ATTR_NO_FILLSTACK = 0x00100000, PSP_THREAD_ATTR_CLEAR_STACK = 0x00200000 }
| Attribute for threads. More...

enum

SceKernelIdListType {
SCE_KERNEL_TMID_Thread = 1, SCE_KERNEL_TMID_Semaphore = 2, SCE_KERNEL_TMID_EventFlag = 3, SCE_KERNEL_TMID_Mbox = 4,
SCE_KERNEL_TMID_Vpl = 5, SCE_KERNEL_TMID_Fpl = 6, SCE_KERNEL_TMID_Mpipe = 7, SCE_KERNEL_TMID_Callback = 8,
SCE_KERNEL_TMID_ThreadEventHandler = 9, SCE_KERNEL_TMID_Alarm = 10, SCE_KERNEL_TMID_VTimer = 11, SCE_KERNEL_TMID_SleepThread = 64,
SCE_KERNEL_TMID_DelayThread = 65, SCE_KERNEL_TMID_SuspendThread = 66, SCE_KERNEL_TMID_DormantThread = 67
}

| Threadman types for sceKernelGetThreadmanIdList. More...

## Functions

SceUID | sceKernelCreateThread (const char *name, SceKernelThreadEntry entry, int initPriority, int stackSize, SceUInt attr, SceKernelThreadOptParam *option)
| Create a thread.
int | sceKernelDeleteThread (SceUID thid)
| Delate a thread.
int | sceKernelStartThread (SceUID thid, SceSize arglen, void *argp)
| Start a created thread.
int | sceKernelExitThread (int status)
| Exit a thread.
int | sceKernelExitDeleteThread (int status)
| Exit a thread and delete itself.
int | sceKernelTerminateThread (SceUID thid)
| Terminate a thread.
int | sceKernelTerminateDeleteThread (SceUID thid)
| Terminate and delete a thread.
int | sceKernelSleepThread (void)
| Sleep thread.
void | sceKernelSleepThreadCB (void)
| Sleep thread but service any callbacks as necessary.
int | sceKernelWakeupThread (SceUID thid)
| Wake a thread previously put into the sleep state.
int | sceKernelCancelWakeupThread (SceUID thid)
| Cancel a thread that was to be woken with sceKernelWakeupThread.
int | sceKernelSuspendThread (SceUID thid)
| Suspend a thread.
int | sceKernelResumeThread (SceUID thid)
| Resume a thread previously put into a suspended state with sceKernelSuspendThread.
int | sceKernelWaitThreadEnd (SceUID thid, SceUInt *timeout)
| Wait until a thread has ended.
int | sceKernelWaitThreadEndCB (SceUID thid, SceUInt *timeout)
| Wait until a thread has ended and handle callbacks if necessary.
void | sceKernelDelayThread (SceUInt delay)
| Delay the current thread by a specified number of microseconds.
void | sceKernelDelayThreadCB (SceUInt delay)
| Delay the current thread by a specified number of microseconds and handle any callbacks.
int | sceKernelChangeCurrentThreadAttr (int unknown, SceUInt attr)
| Modify the attributes of the current thread.
int | sceKernelChangeThreadPriority (SceUID thid, int priority)
| Change the threads current priority.
int | sceKernelGetThreadId (void)
| Get the current thread Id.
int | sceKernelReferThreadStatus (SceUID thid, SceKernelThreadInfo *info)
| Get the status information for the specified thread.
int | sceKernelReferThreadRunStatus (SceUID thid, SceKernelThreadRunStatus *status)
| Retrive the runtime status of a thread.
SceUID | sceKernelCreateSema (const char *name, SceUInt attr, int initVal, int maxVal, SceKernelSemaOptParam *option)
| Creates a new semaphore.
int | sceKernelDeleteSema (SceUID semaid)
| Destroy a semaphore.
int | sceKernelSignalSema (SceUID semaid, int signal)
| Send a signal to a semaphore.
int | sceKernelWaitSema (SceUID semaid, int signal, SceUInt *timeout)
| Lock a semaphore.
int | sceKernelWaitSemaCB (SceUID semaid, int signal, SceUInt *timeout)
| Lock a semaphore a handle callbacks if necessary.
int | sceKernelPollSema (SceUID semaid, int signal)
| Poll a sempahore.
int | sceKernelReferSemaStatus (SceUID semaid, SceKernelSemaInfo *info)
| Retrieve information about a semaphore.
int | sceKernelCreateCallback (const char *name, SceKernelCallbackFunction func, void *arg)
| Create callback.
int | sceKernelCreateEventFlag (const char *name, int unk1, int bits, int unk3)
| Create an event flag.
int | sceKernelSetEventFlag (int evid, u32 bits)
| Set an event flag bit pattern.
int | sceKernelPollEventFlag (int evid, u32 bits, u32 wait, u32 *outBits)
| Poll an event flag for a giveb bit pattern.
int | sceKernelDeleteEventFlag (int evid)
| Delete an event flag.
int | sceKernelGetThreadmanIdList (enum SceKernelIdListType type, SceUID *readbuf, int readbufsize, int *idcount)
| Get a list of UIDs from threadman.
int | sceKernelReferCallbackStatus (SceUID cb, SceKernelCallbackInfo *status)
| Gets the status of a specified callback.
int | sceKernelReferSystemStatus (SceKernelSystemStatus *status)
| Get the current system status.
int | sceKernelReferEventFlagStatus (SceUID event, SceKernelEventFlagInfo *status)
| Get the status of an event flag.
SceUID | sceKernelCreateMbx (const char *name, SceUInt attr, SceKernelMbxOptParam *option)
| Creates a new messagebox.
int | sceKernelDeleteMbx (SceUID mbxid)
| Destroy a messagebox.
int | sceKernelSendMbx (SceUID mbxid, void *message)
| Send a message to a messagebox.
int | sceKernelReceiveMbx (SceUID mbxid, void **pmessage, SceUInt *timeout)
| Wait for a message to arrive in a messagebox.
int | sceKernelReceiveMbxCB (SceUID mbxid, void **pmessage, SceUInt *timeout)
| Wait for a message to arrive in a messagebox and handle callbacks if necessary.
int | sceKernelPollMbx (SceUID mbxid, void **pmessage)
| Check if a message has arrived in a messagebox.
int | sceKernelCancelReceiveMbx (SceUID mbxid, int *pnum)
| Abort all wait operations on a messagebox.
int | sceKernelReferMbxStatus (SceUID mbxid, SceKernelMbxInfo *info)
| Retrieve information about a messagebox.

## Define Documentation

#define THREAD_ATTR_USER PSP_THREAD_ATTR_USER

#define THREAD_ATTR_VFPU PSP_THREAD_ATTR_VFPU

## Typedef Documentation

typedef int(* SceKernelCallbackFunction)(int arg1, int arg2, void *arg)

| Callback function prototype.

typedef struct _SceKernelCallbackInfo SceKernelCallbackInfo

typedef struct _SceKernelEventFlagInfo SceKernelEventFlagInfo

typedef struct SceKernelMbxInfo SceKernelMbxInfo

Current state of a messagebox.

See also:
  sceKernelReferMbxStatus.

typedef struct SceKernelMbxOptParam SceKernelMbxOptParam

| Additional options used when creating messageboxes.

typedef struct SceKernelSemaInfo SceKernelSemaInfo

Current state of a semaphore.

See also:
  sceKernelReferSemaStatus.

typedef struct SceKernelSemaOptParam SceKernelSemaOptParam

| Additional options used when creating semaphores.

typedef struct SceKernelSysClock SceKernelSysClock

| 64-bit system clock type.

typedef struct _SceKernelSystemStatus SceKernelSystemStatus

typedef int(* SceKernelThreadEntry)(SceSize args, void *argp)

typedef struct SceKernelThreadInfo SceKernelThreadInfo

Structure to hold the status information for a thread.

See also:
  sceKernelReferThreadStatus

typedef struct SceKernelThreadOptParam SceKernelThreadOptParam

| Additional options used when creating threads.

typedef struct SceKernelThreadRunStatus SceKernelThreadRunStatus

Statistics about a running thread.

See also:
  sceKernelReferThreadRunStatus.

## Enumeration Type Documentation

enum PspThreadAttributes

Attribute for threads.

Enumerator:

  PSP_THREAD_ATTR_VFPU | Enable VFPU access for the thread.
  PSP_THREAD_ATTR_USER | Start the thread in user mode (done automatically if the thread creating it is in user mode).
  PSP_THREAD_ATTR_USBWLAN | Thread is part of the USB/WLAN API.
  PSP_THREAD_ATTR_VSH | Thread is part of the VSH API.
  PSP_THREAD_ATTR_SCRATCH_SRAM | Allow using scratchpad memory for a thread, NOT USABLE ON V1.0.
  PSP_THREAD_ATTR_NO_FILLSTACK | Disables filling the stack with 0xFF on creation.
  PSP_THREAD_ATTR_CLEAR_STACK | Clear the stack when the thread is deleted.

enum SceKernelIdListType

Threadman types for sceKernelGetThreadmanIdList.

Enumerator:

  SCE_KERNEL_TMID_Thread |
  SCE_KERNEL_TMID_Semaphore |
  SCE_KERNEL_TMID_EventFlag |
  SCE_KERNEL_TMID_Mbox |
  SCE_KERNEL_TMID_Vpl |
  SCE_KERNEL_TMID_Fpl |
  SCE_KERNEL_TMID_Mpipe |
  SCE_KERNEL_TMID_Callback |
  SCE_KERNEL_TMID_ThreadEventHandler |
  SCE_KERNEL_TMID_Alarm |
  SCE_KERNEL_TMID_VTimer |
  SCE_KERNEL_TMID_SleepThread |
  SCE_KERNEL_TMID_DelayThread |
  SCE_KERNEL_TMID_SuspendThread |
  SCE_KERNEL_TMID_DormantThread |

## Function Documentation

int sceKernelCancelReceiveMbx | ( | SceUID | mbxid,
|  | int * | pnum
| ) |

Abort all wait operations on a messagebox.

Example:

       sceKernelCancelReceiveMbx(mbxid, NULL);

Parameters:

  | mbxid | - The mbx id returned from sceKernelCreateMbx
  | pnum | - A pointer to where the number of threads which were waiting on the mbx should be stored (NULL if you don't care)

Returns:
  < 0 on error

int sceKernelCancelWakeupThread | ( | SceUID | thid | ) |

Cancel a thread that was to be woken with sceKernelWakeupThread.

Parameters:

  | thid | - UID of the thread to cancel.

Returns:
  Success if >= 0, an error if < 0.

int sceKernelChangeCurrentThreadAttr | ( | int | unknown,
|  | SceUInt | attr
| ) |

Modify the attributes of the current thread.

Parameters:

  | unknown | - Set to 0.
  | attr | - The thread attributes to modify. One of PspThreadAttributes.

Returns:
  < 0 on error.

int sceKernelChangeThreadPriority | ( | SceUID | thid,
|  | int | priority
| ) |

Change the threads current priority.

Parameters:

  | thid | - The ID of the thread (from sceKernelCreateThread or sceKernelGetThreadId)
  | priority | - The new priority (the lower the number the higher the priority)

Example:

       int thid = sceKernelGetThreadId();
       // Change priority of current thread to 16
       sceKernelChangeThreadPriority(thid, 16);

Returns:
  0 if successful, otherwise the error code.

int sceKernelCreateCallback | ( | const char * | name,
|  | SceKernelCallbackFunction | func,
|  | void * | arg
| ) |

Create callback.

Example:

       int cbid;
       cbid = sceKernelCreateCallback("Exit Callback", exit_cb, NULL);

Parameters:

  | name | - A textual name for the callback
  | func | - A pointer to a function that will be called as the callback
  | arg | - Argument for the callback ?

Returns:
  >= 0 A callback id which can be used in subsequent functions, < 0 an error.

int sceKernelCreateEventFlag | ( | const char * | name,
|  | int | unk1,
|  | int | bits,
|  | int | unk3
| ) |

Create an event flag.

Parameters:

  | name | - The name of the event flag.
  | unk1 | - Unknown, set to 0.
  | bits | - Initial bit pattern.
  | unk3 | - Unknown, set to 0.

Returns:
  < 0 on error. >= 0 event flag id.

Example:

       int evid;
       evid = sceKernelCreateEventFlag("wait_event", 0, 0, 0);

SceUID sceKernelCreateMbx | ( | const char * | name,
|  | SceUInt | attr,
|  | SceKernelMbxOptParam * | option
| ) |

Creates a new messagebox.

Example:

       int mbxid;
       mbxid = sceKernelCreateMbx("MyMessagebox", 0, NULL);

Parameters:

  | name | - Specifies the name of the mbx
  | attr | - Mbx attribute flags (normally set to 0)
  | option | - Mbx options (normally set to NULL)

Returns:
  A messagebox id

SceUID sceKernelCreateSema | ( | const char * | name,
|  | SceUInt | attr,
|  | int | initVal,
|  | int | maxVal,
|  | SceKernelSemaOptParam * | option
| ) |

Creates a new semaphore.

Example:

       int semaid;
       semaid = sceKernelCreateSema("MyMutex", 0, 1, 1, 0);

Parameters:

  | name | - Specifies the name of the sema
  | attr | - Sema attribute flags (normally set to 0)
  | initVal | - Sema initial value
  | maxVal | - Sema maximum value
  | option | - Sema options (normally set to 0)

Returns:
  A semaphore id

SceUID sceKernelCreateThread | ( | const char * | name,
|  | SceKernelThreadEntry | entry,
|  | int | initPriority,
|  | int | stackSize,
|  | SceUInt | attr,
|  | SceKernelThreadOptParam * | option
| ) |

Create a thread.

Example:

       int thid;
       this = sceKernelCreateThread("my_thread", threadFunc, 0x18, 0x10000, 0, NULL);

Parameters:

  | name | - An arbitrary thread name.
  | entry | - The thread function to run when started.
  | initPriority | - The initial priority of the thread. Less if higher priority.
  | stackSize | - The size of the initial stack.
  | attr | - The thread attributes, zero or more of PspThreadAttributes.
  | option | - Additional options specified by SceKernelThreadOptParam.

Returns:
  UID of the created thread, or an error code.

void sceKernelDelayThread | ( | SceUInt | delay | ) |

Delay the current thread by a specified number of microseconds.

Parameters:

  | delay | - Delay in microseconds.

Example:

       sceKernelDelayThread(1000000); // Delay for a second

void sceKernelDelayThreadCB | ( | SceUInt | delay | ) |

Delay the current thread by a specified number of microseconds and handle any callbacks.

Parameters:

  | delay | - Delay in microseconds.

Example:

       sceKernelDelayThread(1000000); // Delay for a second

int sceKernelDeleteEventFlag | ( | int | evid | ) |

Delete an event flag.

Parameters:

  | evid | - The event id returned by sceKernelCreateEventFlag.

Returns:
  < 0 On error

int sceKernelDeleteMbx | ( | SceUID | mbxid | ) |

Destroy a messagebox.

Parameters:

  | mbxid | - The mbxid returned from a previous create call.

Returns:
  Returns the value 0 if its succesful otherwise an error code

int sceKernelDeleteSema | ( | SceUID | semaid | ) |

Destroy a semaphore.

Parameters:

  | semaid | - The semaid returned from a previous create call.

Returns:
  Returns the value 0 if its succesful otherwise -1

int sceKernelDeleteThread | ( | SceUID | thid | ) |

Delate a thread.

Parameters:

  | thid | - UID of the thread to be deleted.

Returns:
  < 0 on error.

int sceKernelExitDeleteThread | ( | int | status | ) |

Exit a thread and delete itself.

Parameters:

  | status | - Exit status

int sceKernelExitThread | ( | int | status | ) |

Exit a thread.

Parameters:

  | status | - Exit status.

int sceKernelGetThreadId | ( | void |  | ) |

Get the current thread Id.

Returns:
  The thread id of the calling thread.

int sceKernelGetThreadmanIdList | ( | enum SceKernelIdListType | type,
|  | SceUID * | readbuf,
|  | int | readbufsize,
|  | int * | idcount
| ) |

Get a list of UIDs from threadman.

Allows you to enumerate resources such as threads or semaphores.

Parameters:

  | type | - The type of resource to list, one of SceKernelIdListType.
  | readbuf | - A pointer to a buffer to store the list.
  | readbufsize | - The size of the buffer in SceUID units.
  | idcount | - Pointer to an integer in which to return the number of ids in the list.

Returns:
  < 0 on error. Either 0 or the same as idcount on success.

int sceKernelPollEventFlag | ( | int | evid,
|  | u32 | bits,
|  | u32 | wait,
|  | u32 * | outBits
| ) |

Poll an event flag for a giveb bit pattern.

Parameters:

  | evid | - The event id returned by sceKernelCreateEventFlag.
  | bits | - The bit pattern to poll for.
  | wait | - 0 to return immediately, 1 to wait until the pattern is matched
  | outBits | - The bit pattern that was matched.

Returns:
  < 0 On error

int sceKernelPollMbx | ( | SceUID | mbxid,
|  | void ** | pmessage
| ) |

Check if a message has arrived in a messagebox.

Example:

       void *msg;
       sceKernelPollMbx(mbxid, &msg);

Parameters:

  | mbxid | - The mbx id returned from sceKernelCreateMbx
  | pmessage | - A pointer to where a pointer to the received message should be stored

Returns:
  < 0 on error (SCE_KERNEL_ERROR_MBOX_NOMSG if the mbx is empty).

int sceKernelPollSema | ( | SceUID | semaid,
|  | int | signal
| ) |

Poll a sempahore.

Parameters:

  | semaid | - UID of the semaphore to poll.
  | signal | - The value to test for.

Returns:
  < 0 on error.

int sceKernelReceiveMbx | ( | SceUID | mbxid,
|  | void ** | pmessage,
|  | SceUInt * | timeout
| ) |

Wait for a message to arrive in a messagebox.

Example:

       void *msg;
       sceKernelReceiveMbx(mbxid, &msg, NULL);

Parameters:

  | mbxid | - The mbx id returned from sceKernelCreateMbx
  | pmessage | - A pointer to where a pointer to the received message should be stored
  | timeout | - Timeout in microseconds

Returns:
  < 0 on error.

int sceKernelReceiveMbxCB | ( | SceUID | mbxid,
|  | void ** | pmessage,
|  | SceUInt * | timeout
| ) |

Wait for a message to arrive in a messagebox and handle callbacks if necessary.

Example:

       void *msg;
       sceKernelReceiveMbxCB(mbxid, &msg, NULL);

Parameters:

  | mbxid | - The mbx id returned from sceKernelCreateMbx
  | pmessage | - A pointer to where a pointer to the received message should be stored
  | timeout | - Timeout in microseconds

Returns:
  < 0 on error.

int sceKernelReferCallbackStatus | ( | SceUID | cb,
|  | SceKernelCallbackInfo * | status
| ) |

Gets the status of a specified callback.

Parameters:

  | cb | - The UID of the callback to refer.
  | status | - Pointer to a status structure. The size parameter should be initialised before calling.

Returns:
  < 0 on error.

int sceKernelReferEventFlagStatus | ( | SceUID | event,
|  | SceKernelEventFlagInfo * | status
| ) |

Get the status of an event flag.

Parameters:

  | event | - The UID of the event.
  | status | - A pointer to a SceKernelEventFlagInfo structure.

Returns:
  < 0 on error.

int sceKernelReferMbxStatus | ( | SceUID | mbxid,
|  | SceKernelMbxInfo * | info
| ) |

Retrieve information about a messagebox.

Parameters:

  | mbxid | - UID of the messagebox to retrieve info for.
  | info | - Pointer to a SceKernelMbxInfo struct to receive the info.

Returns:
  < 0 on error.

int sceKernelReferSemaStatus | ( | SceUID | semaid,
|  | SceKernelSemaInfo * | info
| ) |

Retrieve information about a semaphore.

Parameters:

  | semaid | - UID of the semaphore to retrieve info for.
  | info | - Pointer to a SceKernelSemaInfo struct to receive the info.

Returns:
  < 0 on error.

int sceKernelReferSystemStatus | ( | SceKernelSystemStatus * | status | ) |

Get the current system status.

Parameters:

  | status | - Pointer to a SceKernelSystemStatus structure.

Returns:
  < 0 on error.

int sceKernelReferThreadRunStatus | ( | SceUID | thid,
|  | SceKernelThreadRunStatus * | status
| ) |

Retrive the runtime status of a thread.

Parameters:

  | thid | - UID of the thread to retrive status.
  | status | - Pointer to a SceKernelThreadRunStatus struct to receive the runtime status.

Returns:
  0 if successful, otherwise the error code.

int sceKernelReferThreadStatus | ( | SceUID | thid,
|  | SceKernelThreadInfo * | info
| ) |

Get the status information for the specified thread.

Parameters:

  | thid | - Id of the thread to get status
  | info | - Pointer to the info structure to receive the data. Note: The structures size field should be set to sizeof(SceKernelThreadInfo) before calling this function.

Example:

       SceKernelThreadInfo status;
       status.size = sizeof(SceKernelThreadInfo);
       if(sceKernelReferThreadStatus(thid, &status) == 0)
       { Do something... }

Returns:
  0 if successful, otherwise the error code.

int sceKernelResumeThread | ( | SceUID | thid | ) |

Resume a thread previously put into a suspended state with sceKernelSuspendThread.

Parameters:

  | thid | - UID of the thread to resume.

Returns:
  Success if >= 0, an error if < 0.

int sceKernelSendMbx | ( | SceUID | mbxid,
|  | void * | message
| ) |

Send a message to a messagebox.

Example:

       // Send the message
       sceKernelSendMbx(mbxid, "Hello");

Parameters:

  | mbxid | - The mbx id returned from sceKernelCreateMbx
  | message | - A message to be forwarded to the receiver. The first word in the message will be used by the kernel to link messages together, but the rest is used defined.

Returns:
  < 0 On error.

int sceKernelSetEventFlag | ( | int | evid,
|  | u32 | bits
| ) |

Set an event flag bit pattern.

Parameters:

  | evid | - The event id returned by sceKernelCreateEventFlag.
  | bits | - The bit pattern to set.

Returns:
  < 0 On error

int sceKernelSignalSema | ( | SceUID | semaid,
|  | int | signal
| ) |

Send a signal to a semaphore.

Example:

       // Signal the sema
       sceKernelSignalSema(semaid, 1);

Parameters:

  | semaid | - The sema id returned from sceKernelCreateSema
  | signal | - The amount to signal the sema (i.e. if 2 then increment the sema by 2)

Returns:
  < 0 On error.

int sceKernelSleepThread | ( | void |  | ) |

Sleep thread.

Returns:
  < 0 on error.

void sceKernelSleepThreadCB | ( | void |  | ) |

Sleep thread but service any callbacks as necessary.

Example:

       // Once all callbacks have been setup call this function
       sceKernelSleepThreadCB();

int sceKernelStartThread | ( | SceUID | thid,
|  | SceSize | arglen,
|  | void * | argp
| ) |

Start a created thread.

Parameters:

  | thid | - Thread id from sceKernelCreateThread
  | arglen | - Length of the data pointed to by argp, in bytes
  | argp | - Pointer to the arguments.

int sceKernelSuspendThread | ( | SceUID | thid | ) |

Suspend a thread.

Parameters:

  | thid | - UID of the thread to suspend.

Returns:
  Success if >= 0, an error if < 0.

int sceKernelTerminateDeleteThread | ( | SceUID | thid | ) |

Terminate and delete a thread.

Parameters:

  | thid | - UID of the thread to terminate and delete.

Returns:
  Success if >= 0, an error if < 0.

int sceKernelTerminateThread | ( | SceUID | thid | ) |

Terminate a thread.

Parameters:

  | thid | - UID of the thread to terminate.

Returns:
  Success if >= 0, an error if < 0.

int sceKernelWaitSema | ( | SceUID | semaid,
|  | int | signal,
|  | SceUInt * | timeout
| ) |

Lock a semaphore.

Example:

       sceKernelWaitSema(semaid, 1, 0);

Parameters:

  | semaid | - The sema id returned from sceKernelCreateSema
  | signal | - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1)
  | timeout | - Timeout in microseconds (assumed).

Returns:
  < 0 on error.

int sceKernelWaitSemaCB | ( | SceUID | semaid,
|  | int | signal,
|  | SceUInt * | timeout
| ) |

Lock a semaphore a handle callbacks if necessary.

Example:

       sceKernelWaitSemaCB(semaid, 1, 0);

Parameters:

  | semaid | - The sema id returned from sceKernelCreateSema
  | signal | - The value to wait for (i.e. if 1 then wait till reaches a signal state of 1)
  | timeout | - Timeout in microseconds (assumed).

Returns:
  < 0 on error.

int sceKernelWaitThreadEnd | ( | SceUID | thid,
|  | SceUInt * | timeout
| ) |

Wait until a thread has ended.

Parameters:

  | thid | - Id of the thread to wait for.
  | timeout | - Timeout in microseconds (assumed).

Returns:
  < 0 on error.

int sceKernelWaitThreadEndCB | ( | SceUID | thid,
|  | SceUInt * | timeout
| ) |

Wait until a thread has ended and handle callbacks if necessary.

Parameters:

  | thid | - Id of the thread to wait for.
  | timeout | - Timeout in microseconds (assumed).

Returns:
  < 0 on error.

int sceKernelWakeupThread | ( | SceUID | thid | ) |

Wake a thread previously put into the sleep state.

Parameters:

  | thid | - UID of the thread to wake.

Returns:
  Success if >= 0, an error if < 0.