Remove randomness, only delay with lle
This commit is contained in:
@@ -228,10 +228,10 @@
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="delay_main_thread_start">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Introduces a random delay to the first ever launched app thread, which helps randomness seeding from the system tick. If lle system modules are enabled, the delay will be increased. Disable for more consistent boot times.</p></body></html></string>
|
||||
<string><html><head/><body><p>Introduces a delay to the first ever launched app thread if LLE modules are enabled, to allow them to initialize.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delay app main thread start</string>
|
||||
<string>Delay app main thread start with LLE modules enabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@@ -412,40 +412,33 @@ void Thread::BoostPriority(u32 priority) {
|
||||
std::shared_ptr<Thread> SetupMainThread(KernelSystem& kernel, u32 entry_point, u32 priority,
|
||||
std::shared_ptr<Process> owner_process) {
|
||||
|
||||
constexpr const s64 sleep_random_deviation_ns = 250'000'000LL;
|
||||
constexpr const s64 sleep_normal_thread_base_ns = 250'000'000LL;
|
||||
constexpr const s64 sleep_app_thread_base_ns = 2'500'000'000LL;
|
||||
constexpr const u32 system_module_tid_high = 0x00040130;
|
||||
constexpr s64 sleep_app_thread_ns = 2'600'000'000LL;
|
||||
constexpr u32 system_module_tid_high = 0x00040130;
|
||||
|
||||
const bool is_lle_service =
|
||||
static_cast<u32>(owner_process->codeset->program_id >> 32) == system_module_tid_high;
|
||||
|
||||
s64 sleep_base_time_ns = 0;
|
||||
s64 sleep_time_ns = 0;
|
||||
if (!is_lle_service && Settings::values.delay_main_thread_start) {
|
||||
if (kernel.GetAppMainThreadExtendedSleep()) {
|
||||
sleep_base_time_ns = sleep_app_thread_base_ns;
|
||||
sleep_time_ns = sleep_app_thread_ns;
|
||||
kernel.SetAppMainThreadExtendedSleep(false);
|
||||
} else {
|
||||
sleep_base_time_ns = sleep_normal_thread_base_ns;
|
||||
}
|
||||
std::random_device rand_device;
|
||||
sleep_base_time_ns += (static_cast<s64>(rand_device()) % (sleep_random_deviation_ns * 2)) -
|
||||
sleep_random_deviation_ns;
|
||||
}
|
||||
|
||||
// Initialize new "main" thread
|
||||
auto thread_res =
|
||||
kernel.CreateThread("main", entry_point, priority, 0, owner_process->ideal_processor,
|
||||
Memory::HEAP_VADDR_END, owner_process, sleep_base_time_ns == 0);
|
||||
Memory::HEAP_VADDR_END, owner_process, sleep_time_ns == 0);
|
||||
|
||||
std::shared_ptr<Thread> thread = std::move(thread_res).Unwrap();
|
||||
|
||||
thread->context.fpscr =
|
||||
FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | FPSCR_ROUND_TOZERO | FPSCR_IXC; // 0x03C00010
|
||||
|
||||
if (sleep_base_time_ns != 0) {
|
||||
if (sleep_time_ns != 0) {
|
||||
thread->status = ThreadStatus::WaitSleep;
|
||||
thread->WakeAfterDelay(sleep_base_time_ns);
|
||||
thread->WakeAfterDelay(sleep_time_ns);
|
||||
}
|
||||
|
||||
// Note: The newly created thread will be run when the scheduler fires.
|
||||
|
Reference in New Issue
Block a user