mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-26 17:37:03 +00:00
thread affinity, task_set_exception_ports
This commit is contained in:
parent
062244a722
commit
a7032b1004
|
@ -22,6 +22,9 @@
|
|||
#include <unordered_map>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
void set_thread_affinity();
|
||||
|
||||
extern "C" {
|
||||
#include "x64emu.h"
|
||||
#include "x64run.h"
|
||||
|
@ -305,6 +308,7 @@ static void RunMainEntry(VAddr addr, EntryParams* params, ExitFunc exit_func) {
|
|||
SetRSI(emu, rsi);
|
||||
emu->quit = 0;
|
||||
|
||||
set_thread_affinity();
|
||||
Run(emu, 0);
|
||||
|
||||
UNIMPLEMENTED_MSG("Missing RunMainEntry() implementation for target CPU architecture.");
|
||||
|
@ -334,6 +338,7 @@ void* RunThreadEntry(u64 thread, void* arg) {
|
|||
|
||||
emu->quit = 0;
|
||||
|
||||
set_thread_affinity();
|
||||
Run(emu, 0);
|
||||
|
||||
auto rv = emu->regs[_RAX].q[0];
|
||||
|
@ -414,6 +419,7 @@ void Linker::Execute() {
|
|||
SetRDX(emu, 0);
|
||||
|
||||
emu->quit = 0;
|
||||
set_thread_affinity();
|
||||
Run(emu, 0);
|
||||
}
|
||||
}
|
||||
|
@ -648,6 +654,7 @@ void* heap_api_malloc(Core::HeapAPI* heap_api, size_t size) {
|
|||
SetRSP(emu, rsp);
|
||||
SetRDI(emu, size);
|
||||
|
||||
set_thread_affinity();
|
||||
Run(emu, 0);
|
||||
|
||||
return (void*)emu->regs[_RAX].q[0];
|
||||
|
|
20
src/main.cpp
20
src/main.cpp
|
@ -5,7 +5,19 @@
|
|||
#include "common/memory_patcher.h"
|
||||
#include "emulator.h"
|
||||
|
||||
#include <mach/task.h>
|
||||
#include <mach/mach_init.h>
|
||||
#include <mach/mach_port.h>
|
||||
void set_thread_affinity();
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
set_thread_affinity();
|
||||
task_set_exception_ports(
|
||||
mach_task_self(),
|
||||
EXC_MASK_BAD_ACCESS,
|
||||
MACH_PORT_NULL,//m_exception_port,
|
||||
EXCEPTION_DEFAULT,
|
||||
0);
|
||||
if (argc == 1) {
|
||||
fmt::print("Usage: {} <elf or eboot.bin path>\n", argv[0]);
|
||||
return -1;
|
||||
|
@ -24,3 +36,11 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include <pthread.h>
|
||||
#import <mach/thread_act.h>
|
||||
|
||||
void set_thread_affinity() {
|
||||
thread_affinity_policy_data_t policyData1 = { 1 };
|
||||
thread_policy_set(pthread_mach_thread_np(pthread_self()), THREAD_AFFINITY_POLICY, (thread_policy_t)&policyData1, 1);
|
||||
}
|
Loading…
Reference in a new issue