Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

Thread Manager Library


Detailed Description

Library imports for the kernel threading library.


Data Structures

struct  _ThreadStatus
 Structure to hold the status information for a thread. More...

Typedefs

typedef *struct _ThreadStatus ThreadStatus
 Structure to hold the status information for a thread.

Enumerations

enum  ThreadAttributes { THREAD_ATTR_VFPU = 0x00004000, THREAD_ATTR_USER = 0x80000000 }
 Attribute for threads. More...

Functions

int sceKernelCreateSema (const char *name, int attr, int initVal, int maxVal, int option)
 Creates a new semaphore.
int sceKernelDeleteSema (int semaid)
 Destroy a semaphore.
int sceKernelSignalSema (int semaid, int signal)
 Send a signal to a semaphore.
int sceKernelWaitSema (int semaid, int signal, int unknown)
 Lock a semaphore.
int sceKernelWaitSemaCB (int semaid, int signal, int unknown)
 Lock a semaphore a handle callbacks if necessary.
int sceKernelSleepThread (void)
 Sleep thread.
int sceKernelCreateThread (const char *name, void *func, int initPriority, int stacksize, int attributes, int option)
 Create a thread.
int sceKernelDeleteThread (int thid)
 Delate a thread.
int sceKernelStartThread (int thid, int arglen, void *args)
 Start a created thread.
int sceKernelExitThread (int status)
 Exit a thread.
int sceKernelCreateCallback (const char *name, void *func, void *arg)
 Create callback.
void sceKernelSleepThreadCB (void)
 Sleep thread but service any callbacks as necessary.
int sceKernelGetThreadId (void)
 Get the current thread Id.
void sceKernelDelayThread (int delay)
 Delay the current thread by a specified number of microseconds.
void sceKernelDelayThreadCB (int delay)
 Delay the current thread by a specified number of microseconds and handle any callbacks.
int sceKernelChangeThreadPriority (int thid, int priority)
 Change the threads current priority.
int sceKernelReferThreadStatus (int thid, ThreadStatus *status)
 Get the status information for the specified thread.
int sceKernelWaitEndThread (int thid, void *unk)
 Wait until a thread has ended.
int sceKernelWaitEndThreadCB (int thid, void *unk)
 Wait until a thread has ended and handle callbacks if necessary.
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.


Typedef Documentation

typedef * struct _ThreadStatus ThreadStatus
 

Structure to hold the status information for a thread.

See also:
sceKernelReferThreadStatus


Enumeration Type Documentation

enum ThreadAttributes
 

Attribute for threads.

Enumerator:
THREAD_ATTR_VFPU  Enable VFPU access for the thread.
THREAD_ATTR_USER  Start the thread in user mode (done automatically if the thread creating it is in user mode).


Function Documentation

int sceKernelChangeThreadPriority (  int  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,
void *  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);

int sceKernelCreateSema (  const char *  name,
int  attr,
int  initVal,
int  maxVal,
int  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

int sceKernelCreateThread (  const char *  name,
void *  func,
int  initPriority,
int  stacksize,
int  attributes,
int  option
) 
 

Create a thread.

Example:
 int thid;
 this = sceKernelCreateThread("my_thread", threadFunc, 0x18, 0x10000, 0, 0);
Parameters:
name - An arbitrary thread name.
func - 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.
attributes - The thread attributes, zero or more of ThreadAttributes.
option - An optional parameter (always 0?)
Returns:
< 0 on error, >= 0 Thread ID for use in subsequent functions.

void sceKernelDelayThread (  int  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 (  int  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 sceKernelDeleteSema (  int  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 (  int  thid  ) 
 

Delate a thread.

Parameters:
thid - UID of the thread to be deleted.
Returns:
< 0 on error.

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 sceKernelReferThreadStatus (  int  thid,
ThreadStatus *  status
) 
 

Get the status information for the specified thread.

Parameters:
thid - Id of the thread to get status
status - Pointer to the status structure to receive the data. Note: The structures size field should be set to sizeof(ThreadStatus) before calling this function.
Example:
 ThreadStatus status;
 status.size = sizeof(ThreadStatus);
 if(sceKernelReferThreadStatus(thid, &status) == 0)
 { Do something... }
Returns:
0 if successful, otherwise the error code.

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 (  int  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 (  int  thid,
int  arglen,
void *  args
) 
 

Start a created thread.

Example:
Parameters:
thid - Thread id from sceKernelCreateThread
arglen - Length of the args pointed to by the args parameter
args - Pointer to the arguments.

int sceKernelWaitEndThread (  int  thid,
void *  unk
) 
 

Wait until a thread has ended.

Parameters:
thid - Id of the thread to wait for.
unk - Unknown, set to 0.
Returns:
< 0 on error.

int sceKernelWaitEndThreadCB (  int  thid,
void *  unk
) 
 

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

Parameters:
thid - Id of the thread to wait for.
unk - Unknown, set to 0.
Returns:
< 0 on error.

int sceKernelWaitSema (  int  semaid,
int  signal,
int  unknown
) 
 

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)
unknown - Unknown.
Returns:
< 0 on error.

int sceKernelWaitSemaCB (  int  semaid,
int  signal,
int  unknown
) 
 

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)
unknown - Unknown.
Returns:
< 0 on error.


Generated on Tue Jun 28 03:32:56 2005 for pspsdk-1.0+beta by  doxygen 1.4.3-20050530