mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-06-15 11:58:44 +02:00
7ad2e11705
This commit adds the Services API and implements some services. It also changes the name of the application to Skyline and replaces the icon.
29 lines
1.5 KiB
C++
29 lines
1.5 KiB
C++
#include <sys/resource.h>
|
|
#include "KThread.h"
|
|
#include "KProcess.h"
|
|
#include "../../nce.h"
|
|
|
|
namespace skyline::kernel::type {
|
|
KThread::KThread(handle_t handle, pid_t parent_pid, const DeviceState &state, pid_t self_pid, u64 entryPoint, u64 entryArg, u64 stackTop, u64 tls, u8 priority, KProcess *parent) : pid(self_pid), entryPoint(entryPoint), entryArg(entryArg), stackTop(stackTop), tls(tls), priority(priority), parent(parent), KSyncObject(handle, parent_pid, state, KType::KThread) {
|
|
UpdatePriority(priority);
|
|
}
|
|
|
|
KThread::~KThread() {
|
|
kill(pid, SIGKILL);
|
|
}
|
|
|
|
void KThread::Start() {
|
|
if (pid == parent->mainThread)
|
|
parent->status = KProcess::ProcessStatus::Started;
|
|
status = ThreadStatus::Running;
|
|
state.nce->StartProcess(entryPoint, entryArg, stackTop, handle, pid);
|
|
}
|
|
|
|
void KThread::UpdatePriority(u8 priority) {
|
|
this->priority = priority;
|
|
auto liPriority = static_cast<int8_t>(constant::PriorityAn.first + ((static_cast<float>(constant::PriorityAn.second - constant::PriorityAn.first) / static_cast<float>(constant::PriorityNin.second - constant::PriorityNin.first)) * (static_cast<float>(priority) - constant::PriorityNin.first))); // Resize range PriorityNin (Nintendo Priority) to PriorityAn (Android Priority)
|
|
if (setpriority(PRIO_PROCESS, static_cast<id_t>(pid), liPriority) == -1)
|
|
throw exception(fmt::format("Couldn't set process priority to {} for PID: {}", liPriority, pid));
|
|
}
|
|
}
|