Skip to main content

Overview

The process API provides functions for managing processes, retrieving process information, and controlling process execution on the PlayStation 3.

Process Information

sysProcessGetPid

Get the current process ID.
sys_pid_t sysProcessGetPid(void);
return
sys_pid_t
Current process ID
Example:
sys_pid_t pid = sysProcessGetPid();
printf("Process ID: %u\n", pid);

sysProcessGetPpid

Get the parent process ID.
sys_pid_t sysProcessGetPpid(void);
return
sys_pid_t
Parent process ID

sysProcessGetNumberOfObject

Get the number of objects of a specific type.
s32 sysProcessGetNumberOfObject(u32 object, size_t *numptr);
object
u32
required
Object type constant:
  • SYS_OBJECT_MEM - Memory objects
  • SYS_OBJECT_MUTEX - Mutexes
  • SYS_OBJECT_COND - Condition variables
  • SYS_OBJECT_EVENT_QUEUE - Event queues
  • SYS_OBJECT_SEMAPHORE - Semaphores
  • SYS_OBJECT_FS_FD - File descriptors
  • And others (see constants below)
numptr
size_t*
required
Pointer to storage for object count
return
s32
Zero on success, error code otherwise
Example:
size_t mutex_count;
s32 ret = sysProcessGetNumberOfObject(SYS_OBJECT_MUTEX, &mutex_count);
if (ret == 0) {
    printf("Active mutexes: %zu\n", mutex_count);
}

sysProcessGetPpuGuid

Get PPU GUID information from the ELF.
sys_addr_t sysProcessGetPpuGuid(void);
return
sys_addr_t
Address of PPU GUID information

Process Control

sysProcessExit

Terminate the current process.
void sysProcessExit(int status) __attribute__((noreturn));
status
int
required
Exit status code
Example:
if (critical_error) {
    sysProcessExit(1);
}

sysProcessExitSpawn2

Terminate the current process and execute another program.
void sysProcessExitSpawn2(const char *path,
                          const char *argv[],
                          const char *envp[],
                          void *data,
                          size_t size,
                          int priority,
                          u64 flags);
path
const char*
required
Path to the new program to execute
argv
const char*[]
required
Argument vector for the new program (NULL-terminated)
envp
const char*[]
Environment variables (may be NULL)
data
void*
Additional data to pass (may be NULL)
size
size_t
Size of additional data
priority
int
required
Priority for the new process (1000 = normal)
flags
u64
required
Stack size flags (OR combination):
  • SYS_PROCESS_SPAWN_STACK_SIZE_32K
  • SYS_PROCESS_SPAWN_STACK_SIZE_64K
  • SYS_PROCESS_SPAWN_STACK_SIZE_96K
  • SYS_PROCESS_SPAWN_STACK_SIZE_128K
  • SYS_PROCESS_SPAWN_STACK_SIZE_256K
  • SYS_PROCESS_SPAWN_STACK_SIZE_512K
  • SYS_PROCESS_SPAWN_STACK_SIZE_1M
Example:
const char *argv[] = { "/dev_hdd0/game/GAME00001/USRDIR/EBOOT.BIN", NULL };
sysProcessExitSpawn2("/dev_hdd0/game/GAME00001/USRDIR/EBOOT.BIN",
                     argv, NULL, NULL, 0, 1000,
                     SYS_PROCESS_SPAWN_STACK_SIZE_1M);

Process Parameters

Define process priority and stack size using the SYS_PROCESS_PARAM macro in your code.

SYS_PROCESS_PARAM

Define process parameters (must be used outside functions).
SYS_PROCESS_PARAM(priority, stacksize)
priority
s32
required
Process priority (1000 = normal)
stacksize
u32
required
Main thread stack size constant:
  • SYS_PROCESS_SPAWN_STACK_SIZE_32K (0x10)
  • SYS_PROCESS_SPAWN_STACK_SIZE_64K (0x20)
  • SYS_PROCESS_SPAWN_STACK_SIZE_96K (0x30)
  • SYS_PROCESS_SPAWN_STACK_SIZE_128K (0x40)
  • SYS_PROCESS_SPAWN_STACK_SIZE_256K (0x50)
  • SYS_PROCESS_SPAWN_STACK_SIZE_512K (0x60)
  • SYS_PROCESS_SPAWN_STACK_SIZE_1M (0x70)
Example:
#include <sys/process.h>

SYS_PROCESS_PARAM(1000, SYS_PROCESS_SPAWN_STACK_SIZE_1M)

int main(void) {
    // Your code here
    return 0;
}

Object Type Constants

Constants for use with sysProcessGetNumberOfObject():
ConstantValueDescription
SYS_OBJECT_MEM0x08Memory objects
SYS_OBJECT_MUTEX0x85Mutexes
SYS_OBJECT_COND0x86Condition variables
SYS_OBJECT_RWLOCK0x88Read-write locks
SYS_OBJECT_INTR_TAG0x0AInterrupt tags
SYS_OBJECT_INTR_SERVICE_HANDLE0x0BInterrupt service handles
SYS_OBJECT_EVENT_QUEUE0x8DEvent queues
SYS_OBJECT_EVENT_PORT0x0EEvent ports
SYS_OBJECT_TRACE0x21Trace objects
SYS_OBJECT_SPUIMAGE0x22SPU images
SYS_OBJECT_PRX0x23PRX modules
SYS_OBJECT_SPUPORT0x24SPU ports
SYS_OBJECT_LWMUTEX0x95Lightweight mutexes
SYS_OBJECT_TIMER0x11Timers
SYS_OBJECT_SEMAPHORE0x96Semaphores
SYS_OBJECT_FS_FD0x73File descriptors
SYS_OBJECT_LWCOND0x97Lightweight condition variables
SYS_OBJECT_EVENT_FLAG0x98Event flags

Stack Size Constants

ConstantValueSize
SYS_PROCESS_SPAWN_STACK_SIZE_32K0x1032 KB
SYS_PROCESS_SPAWN_STACK_SIZE_64K0x2064 KB
SYS_PROCESS_SPAWN_STACK_SIZE_96K0x3096 KB
SYS_PROCESS_SPAWN_STACK_SIZE_128K0x40128 KB
SYS_PROCESS_SPAWN_STACK_SIZE_256K0x50256 KB
SYS_PROCESS_SPAWN_STACK_SIZE_512K0x60512 KB
SYS_PROCESS_SPAWN_STACK_SIZE_1M0x701 MB

Process Parameter Structure

typedef struct _sys_process_param {
    u32 size;              // Structure size
    u32 magic;             // Magic number (SYS_PROCESS_SPAWN_MAGIC)
    u32 version;           // Version
    u32 sdk_version;       // SDK version
    s32 prio;              // Priority
    u32 stacksize;         // Stack size
    u32 malloc_pagesize;   // Malloc page size
    u32 ppc_seg;           // PPC segment type
} sys_process_param_t;

Header Files

#include <sys/process.h>  // Process management functions
#include <lv2/process.h>  // Process control functions

See Also

Build docs developers (and LLMs) love