Skip to content

Commit

Permalink
Threadmgr: add cpu affinity masks
Browse files Browse the repository at this point in the history
  • Loading branch information
isage committed Apr 17, 2022
1 parent fd84c21 commit 311c5e7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/psp2/kernel/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
#ifndef _PSP2_KERNEL_CPU_H_
#define _PSP2_KERNEL_CPU_H_

#define SCE_KERNEL_CPU_MASK_USER_0 0x00010000
#define SCE_KERNEL_CPU_MASK_USER_1 0x00020000
#define SCE_KERNEL_CPU_MASK_USER_2 0x00040000
#define SCE_KERNEL_CPU_MASK_SYSTEM 0x00080000

#define SCE_KERNEL_CPU_MASK_USER_ALL \
(SCE_KERNEL_CPU_MASK_USER_0 | SCE_KERNEL_CPU_MASK_USER_1 | SCE_KERNEL_CPU_MASK_USER_2)


#ifdef __cplusplus
extern "C" {
#endif
Expand Down
14 changes: 14 additions & 0 deletions include/psp2/kernel/threadmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#define _PSP2_KERNEL_THREADMGR_H_

#include <psp2/types.h>
#include <psp2/kernel/cpu.h>

/** Inherit calling thread affinity mask. */
#define SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT (0)

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -125,6 +129,16 @@ typedef enum SceKernelMutexAttribute {
* @param stackSize - The size of the initial stack.
* @param attr - The thread attributes, zero or more of ::SceThreadAttributes.
* @param cpuAffinityMask - The CPU affinity mask
* A thread can run only on the cores specified in the CPU affinity mask.
* The CPU affinity mask can be specified by the logical sum of the following macros:
* - SCE_KERNEL_CPU_MASK_USER_0
* - SCE_KERNEL_CPU_MASK_USER_1
* - SCE_KERNEL_CPU_MASK_USER_2
* - SCE_KERNEL_CPU_MASK_SYSTEM (system-reserved core)
* The following macro are also available to represent all available in userland CPU cores:
* - SCE_KERNEL_CPU_MASK_USER_ALL
* The following macro are also available to inherit affinity mask of the calling thread:
* - SCE_KERNEL_THREAD_CPU_AFFINITY_MASK_DEFAULT
* @param option - Additional options specified by ::SceKernelThreadOptParam.
* @return UID of the created thread, or an error code.
Expand Down

0 comments on commit 311c5e7

Please sign in to comment.