Skip to content

Commit

Permalink
[orbis-kernel] fix ucontext freeze, remove hack for mono
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Jan 14, 2024
1 parent 8913659 commit f4adc1e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
17 changes: 5 additions & 12 deletions orbis-kernel/src/sys/sys_sce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,6 @@ orbis::SysResult orbis::sys_resume_internal_hdd(Thread *thread /* TODO */) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_thr_suspend_ucontext(Thread *thread, lwpid_t tid) {
// ORBIS_LOG_FATAL(__FUNCTION__, tid);
auto t = tid == thread->tid ? thread
: thread->tproc->threadsMap.get(tid % 10000 - 1);
if (t == nullptr) {
Expand All @@ -1327,6 +1326,7 @@ orbis::SysResult orbis::sys_thr_suspend_ucontext(Thread *thread, lwpid_t tid) {
while (true) {
unsigned prevSuspend = 0;
if (t->suspended.compare_exchange_strong(prevSuspend, 1)) {
t->suspended.fetch_sub(1);
t->suspend();

while (t->suspended == 0) {
Expand All @@ -1344,22 +1344,16 @@ orbis::SysResult orbis::sys_thr_suspend_ucontext(Thread *thread, lwpid_t tid) {
return {};
}
orbis::SysResult orbis::sys_thr_resume_ucontext(Thread *thread, lwpid_t tid) {
// ORBIS_LOG_FATAL(__FUNCTION__, tid);
auto t = tid == thread->tid ? thread
: thread->tproc->threadsMap.get(tid % 10000 - 1);
if (t == nullptr) {
return ErrorCode::SRCH;
}

while (true) {
unsigned prevSuspend = 1;
if (t->suspended.compare_exchange_strong(prevSuspend, 0)) {
unsigned prevSuspend = t->suspended.load();
if (t->suspended == prevSuspend) {
t->resume();

while (t->suspended != 0) {
std::this_thread::yield();
}

break;
}

Expand All @@ -1375,7 +1369,6 @@ orbis::SysResult orbis::sys_thr_resume_ucontext(Thread *thread, lwpid_t tid) {
}
orbis::SysResult orbis::sys_thr_get_ucontext(Thread *thread, lwpid_t tid,
ptr<UContext> context) {
// ORBIS_LOG_FATAL(__FUNCTION__, tid, context);

auto t = tid == thread->tid ? thread
: thread->tproc->threadsMap.get(tid % 10000 - 1);
Expand All @@ -1390,12 +1383,12 @@ orbis::SysResult orbis::sys_thr_get_ucontext(Thread *thread, lwpid_t tid,
}

for (auto it = t->sigReturns.rbegin(); it != t->sigReturns.rend(); ++it) {
auto &savedContext = t->sigReturns.back();
auto &savedContext = *it;
if (savedContext.mcontext.rip < 0x100'0000'0000) {
return uwrite(context, savedContext);
}
}
ORBIS_LOG_FATAL(__FUNCTION__, "not found guest context");
ORBIS_LOG_FATAL(__FUNCTION__, tid, "not found guest context");
*context = {};
return {};
}
Expand Down
9 changes: 0 additions & 9 deletions rpcsx-os/ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -871,15 +871,6 @@ SysResult execve(Thread *thread, ptr<char> fname, ptr<ptr<char>> argv,

pthread_setname_np(pthread_self(), name.c_str());
}

if (fname == std::string_view{"/app0/eboot.bin"}) {
// FIXME: remove hack
// _envv.push_back("MONO_LOG_LEVEL=debug");
_envv.push_back("MONO_GC_PARAMS=nursery-size=128m");
// _envv.push_back("MONO_GC_DEBUG=2,heap-dump=/app0/mono.dump");
// _envv.push_back("GC_DONT_GC");
}

std::printf("pid: %u\n", ::getpid());

// if (thread->tid == 60001) {
Expand Down

0 comments on commit f4adc1e

Please sign in to comment.