PSP Development/Multithreading

The PSP allows for multiple threads, but there is only one core with a single thread. This means there is no such optimization with making more than one thread. In computers, this is a big drawback and why dual cores and quad cores will always out-perform a computer with a mono core. For archaic prevention, sticking to one thread, with additional threads for additional modules (AI, GUI tweening, [w:Spawn_(computing)|Spawning] independent modules).

There are 3 types of threads available: regular threads, semaphores, and mutices (mutexes).

PSP Program Flow

edit

When the kernel gives control to the program, it does so in two different user-spaces. The first user-space is named 'user' and the second named 'kernel'. Some things are impossible to do in the user thread, and rely on being in a kernel thread. Messing around in the kernel thread is a good way to brick a PSP.

To control what thread the PSP starts in, the function PSP_MAIN_THREAD_ATTR() should be utilized with attribute PSP_MODULE_USER for user mode. This is automatically done if the function PSP_MAIN_THREAD_ATTR() is supplied with PSP_THREAD_ATTR_USER. Although, PSP_MODULE_KERNEL and PSP_THREAD_ATTR_KERNEL should be used respectively for kernel mode.

After the kernel thread dies, "user mode", or the user thread, is entered and executed. This happens directly when the program doesn't enter "kernel mode".