PSL1GHT provides process management APIs for controlling application lifecycle, retrieving system information, and configuring process parameters on the PlayStation 3.
Overview
Process functionality is provided through:
sys/process.h - Process syscalls and configuration
lv2/process.h - Process lifecycle functions
Process Types
typedef u32 sys_pid_t ; // Process ID
typedef u32 sys_program_segment_t ; // Program segment ID
typedef u32 sys_overlay_t ; // Overlay module ID
Process Configuration
Process Parameters
Every PSL1GHT application must define process parameters using the SYS_PROCESS_PARAM macro.
Process Parameter Structure
SYS_PROCESS_PARAM Macro
typedef struct _sys_process_param {
u32 size; // Structure size
u32 magic; // Magic number (0x13bcc5f6)
u32 version; // SDK version
u32 sdk_version; // Firmware version
s32 prio; // Process priority
u32 stacksize; // Main thread stack size
u32 malloc_pagesize; // Malloc page size
u32 ppc_seg; // PPC segment type
} sys_process_param_t ;
Process priority (1000 = normal, lower = higher priority)
Main thread stack size. Use predefined constants or custom value.
The SYS_PROCESS_PARAM macro must be used exactly once at global scope in your application, or the application will fail to run.
Stack Size Constants
Stack Size Options
Example with Named Size
#include <sys/process.h>
#define SYS_PROCESS_SPAWN_STACK_SIZE_32K 0x 10
#define SYS_PROCESS_SPAWN_STACK_SIZE_64K 0x 20
#define SYS_PROCESS_SPAWN_STACK_SIZE_96K 0x 30
#define SYS_PROCESS_SPAWN_STACK_SIZE_128K 0x 40
#define SYS_PROCESS_SPAWN_STACK_SIZE_256K 0x 50
#define SYS_PROCESS_SPAWN_STACK_SIZE_512K 0x 60
#define SYS_PROCESS_SPAWN_STACK_SIZE_1M 0x 70
Advanced Process Parameters
For applications using overlay modules: SYS_PROCESS_PARAM_OVLM (priority, stacksize)
This variant configures the process for overlay module support, which allows loading code modules dynamically.
For PRX (PlayStation Relocatable eXecutable) modules: SYS_PROCESS_PARAM_FIXED (priority, stacksize)
This variant is used for loadable modules that require fixed addressing.
// SDK Versions
#define SYS_PROCESS_SPAWN_VERSION_1 0x 00000001
#define SYS_PROCESS_SPAWN_VERSION_084 0x 00008400
#define SYS_PROCESS_SPAWN_VERSION_090 0x 00009000
#define SYS_PROCESS_SPAWN_VERSION_330 0x 00330000
// Firmware Versions
#define SYS_PROCESS_SPAWN_FW_VERSION_192 0x 00192001
#define SYS_PROCESS_SPAWN_FW_VERSION_330 0x 00330000
// Page Sizes for malloc
#define SYS_PROCESS_SPAWN_MALLOC_PAGE_SIZE_NONE 0x 00000000
#define SYS_PROCESS_SPAWN_MALLOC_PAGE_SIZE_64K 0x 00010000
#define SYS_PROCESS_SPAWN_MALLOC_PAGE_SIZE_1M 0x 00100000
Process IDs
Process ID Functions
Example
LV2_SYSCALL sysProcessGetPid ( void );
LV2_SYSCALL sysProcessGetPpid ( void );
Returns the current process ID
Returns the parent process ID
sysProcessGetNumberOfObject
Example
LV2_SYSCALL sysProcessGetNumberOfObject (u32 object , size_t * numptr );
Object type to query (see object types below)
Pointer to receive the object count
System Object Types
Object Type Constants
Query Multiple Objects
#define SYS_OBJECT_MEM ( 0x 08 UL )
#define SYS_OBJECT_MUTEX ( 0x 85 UL )
#define SYS_OBJECT_COND ( 0x 86 UL )
#define SYS_OBJECT_RWLOCK ( 0x 88 UL )
#define SYS_OBJECT_INTR_TAG ( 0x 0A UL )
#define SYS_OBJECT_INTR_SERVICE_HANDLE ( 0x 0B UL )
#define SYS_OBJECT_EVENT_QUEUE ( 0x 8D UL )
#define SYS_OBJECT_EVENT_PORT ( 0x 0E UL )
#define SYS_OBJECT_TRACE ( 0x 21 UL )
#define SYS_OBJECT_SPUIMAGE ( 0x 22 UL )
#define SYS_OBJECT_PRX ( 0x 23 UL )
#define SYS_OBJECT_SPUPORT ( 0x 24 UL )
#define SYS_OBJECT_LWMUTEX ( 0x 95 UL )
#define SYS_OBJECT_TIMER ( 0x 11 UL )
#define SYS_OBJECT_SEMAPHORE ( 0x 96 UL )
#define SYS_OBJECT_FS_FD ( 0x 73 UL )
#define SYS_OBJECT_LWCOND ( 0x 97 UL )
#define SYS_OBJECT_EVENT_FLAG ( 0x 98 UL )
sysProcessGetPpuGuid
Example
LV2_SYSCALL sysProcessGetPpuGuid ( void );
Returns the address of the PPU GUID information from the ELF
Process Lifecycle
Exiting Processes
void sysProcessExit ( int status ) __attribute__ ((noreturn));
Exit status code (0 = success, non-zero = error)
sysProcessExit() does not return. All cleanup should be done before calling this function.
Exit and Spawn
sysProcessExitSpawn2
Example
void sysProcessExitSpawn2 ( const char * path ,
const char * argv [] ,
const char * envp [] ,
void * data ,
size_t size ,
int priority ,
u64 flags );
Full path to the executable to launch
Command-line arguments (NULL-terminated array)
Environment variables (NULL-terminated array, can be NULL)
Additional data to pass to new process (can be NULL)
Priority for the new process
Process spawn flags (stack size, etc.)
This function only returns if spawning fails. On success, the current process is replaced by the new one.
Advanced Features
SPU Lock Line Reservation
sysProcessIsSpuLockLinkReservation
Example
LV2_SYSCALL sysProcessIsSpuLockLinkReservation (u32 addr , u64 flags );
Complete Process Example
Application Lifecycle Example
#include <stdio.h>
#include <stdlib.h>
#include <sys/process.h>
#include <lv2/process.h>
// Define process parameters (REQUIRED)
SYS_PROCESS_PARAM ( 1000 , SYS_PROCESS_SPAWN_STACK_SIZE_1M)
void print_process_info () {
sys_pid_t pid = sysProcessGetPid ();
sys_pid_t ppid = sysProcessGetPpid ();
printf ( "Process ID: %u \n " , pid);
printf ( "Parent Process ID: %u \n " , ppid);
}
void print_resource_usage () {
size_t count;
printf ( " \n Resource Usage: \n " );
if ( sysProcessGetNumberOfObject (SYS_OBJECT_MUTEX, & count) == 0 )
printf ( " Mutexes: %zu \n " , count);
if ( sysProcessGetNumberOfObject (SYS_OBJECT_COND, & count) == 0 )
printf ( " Condition Variables: %zu \n " , count);
if ( sysProcessGetNumberOfObject (SYS_OBJECT_FS_FD, & count) == 0 )
printf ( " File Descriptors: %zu \n " , count);
if ( sysProcessGetNumberOfObject (SYS_OBJECT_EVENT_QUEUE, & count) == 0 )
printf ( " Event Queues: %zu \n " , count);
}
int main ( int argc , char * argv [] ) {
printf ( "Application started \n " );
// Print process information
print_process_info ();
// Print command line arguments
printf ( " \n Command line arguments: \n " );
for ( int i = 0 ; i < argc; i ++ ) {
printf ( " argv[ %d ]: %s \n " , i, argv [i]);
}
// Do application work...
printf ( " \n Running application... \n " );
// Print resource usage
print_resource_usage ();
// Clean exit
printf ( " \n Application exiting normally \n " );
sysProcessExit ( 0 );
return 0 ; // Never reached
}
Error Handling Example
Error Handling and Cleanup
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/process.h>
#include <lv2/process.h>
SYS_PROCESS_PARAM ( 1000 , SYS_PROCESS_SPAWN_STACK_SIZE_512K)
static volatile int g_running = 1 ;
void cleanup_resources () {
printf ( "Cleaning up resources... \n " );
// Close files, destroy mutexes, etc.
printf ( "Cleanup complete \n " );
}
void signal_handler ( int sig ) {
printf ( "Received signal %d \n " , sig);
g_running = 0 ;
}
int main ( int argc , char * argv [] ) {
// Set up signal handlers
signal (SIGINT, signal_handler);
signal (SIGTERM, signal_handler);
printf ( "Application running (press Ctrl+C to exit) \n " );
// Main loop
while (g_running) {
// Do work...
usleep ( 100000 ); // 100ms
}
// Cleanup before exit
cleanup_resources ();
printf ( "Exiting gracefully \n " );
sysProcessExit ( 0 );
return 0 ;
}
Application Launcher Example
Simple Application Launcher
#include <stdio.h>
#include <string.h>
#include <lv2/process.h>
#include <sys/process.h>
SYS_PROCESS_PARAM ( 1000 , SYS_PROCESS_SPAWN_STACK_SIZE_256K)
void launch_game ( const char * game_id ) {
char path [ 256 ];
const char * argv [ 2 ];
// Build path to game
snprintf (path, sizeof (path),
"/dev_hdd0/game/ %s /USRDIR/EBOOT.BIN" , game_id);
// Set up arguments
argv [ 0 ] = "EBOOT.BIN" ;
argv [ 1 ] = NULL ;
printf ( "Launching: %s \n " , path);
// Exit and spawn the game
sysProcessExitSpawn2 (path,
argv,
NULL , // No environment
NULL , // No extra data
0 ,
1000 , // Normal priority
SYS_PROCESS_SPAWN_STACK_SIZE_1M);
// Only reached if spawn fails
printf ( "ERROR: Failed to launch %s \n " , game_id);
sysProcessExit ( 1 );
}
int main ( int argc , char * argv [] ) {
if (argc < 2 ) {
printf ( "Usage: %s <GAME_ID> \n " , argv [ 0 ]);
sysProcessExit ( 1 );
}
launch_game ( argv [ 1 ]);
return 0 ;
}
Best Practices
Always Define Parameters Every application must call SYS_PROCESS_PARAM exactly once at global scope.
Clean Exit Perform all cleanup before calling sysProcessExit().
Monitor Resources Use sysProcessGetNumberOfObject() to track resource usage.
Handle Arguments Properly parse and validate argc and argv parameters.
Common Mistakes:
Forgetting to include SYS_PROCESS_PARAM (application won’t start)
Using exit() instead of sysProcessExit() (may not clean up properly)
Not NULL-terminating argv arrays for sysProcessExitSpawn2()
Setting stack size too small (causes crashes)
Process Priority Guidelines
Priority Recommendations:
0-99 : System-critical tasks (avoid)
100-999 : High-priority application tasks
1000 : Normal application priority (recommended default)
1001-3000 : Background tasks
3001+ : Very low priority tasks
See Also