Commit Graph

54 Commits (985d0f35e55f0752c6e147d0140b367708499cb4)

Author SHA1 Message Date
Fernando Sahmkow e4a1ead897 Core: Refactor CpuCoreManager to CpuManager and Cpu to Core Manager.
This commit instends on better naming the new purpose of this classes.
5 years ago
Fernando Sahmkow 40cd4df584 CpuCore: Clear exclusive state after doing a run in dynarmic.
This commit corrects an error in which a Core could remain with an
exclusive state after running, leaving space for possible race
conditions between changing cores.
5 years ago
bunnei 9046d4a548
kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects. (#3154)
* kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for kernel objects.

- See https://github.com/citra-emu/citra/pull/4710 for details.
5 years ago
Lioncash 12dc918937 kernel: Resolve sign conversion warnings
Uncovered a bug within Thread's SetCoreAndAffinityMask() where an
unsigned variable (ideal_core) was being compared against "< 0", which
would always be a false condition.

We can also get rid of an unused function (GetNextProcessorId) which contained a sign
mismatch warning.
5 years ago
Lioncash 6c8f28813c scheduler: Mark parameter of AskForReselectionOrMarkRedundant() as const
This is only compared against, so it can be made const.
6 years ago
Lioncash f19c1a7cda scheduler: Silence sign conversion warnings 6 years ago
Lioncash 2fb0bbff29 scheduler: Initialize class members directly where applicable
Reduces the overall amount of code.
6 years ago
Lioncash 2dc469ceba scheduler: Amend documentation comments
Adjusts the formatting of a few of the comments an ensures they get
recognized as proper Doxygen comments.
6 years ago
Fernando Sahmkow a3524879be Kernel: Clang Format 6 years ago
Fernando Sahmkow 3073615dbc Kernel: Address Feedback. 6 years ago
Fernando Sahmkow 25f8606a6d Kernel Scheduler: Make sure the global scheduler shutdowns correctly. 6 years ago
Fernando Sahmkow 1ec1e81373 Kernel: Clang Format 6 years ago
Fernando Sahmkow e05a8c2385 Kernel: Remove global system accessor from WaitObject 6 years ago
Fernando Sahmkow 0cf26cee59 Scheduler: Implement Yield Count and Core migration on Thread Preemption. 6 years ago
Fernando Sahmkow 2d382de6fa Scheduler: Corrections to YieldAndBalanceLoad and Yield bombing protection. 6 years ago
Fernando Sahmkow b49c0dab87 Kernel: Initial implementation of thread preemption. 6 years ago
Fernando Sahmkow 103f3a2fe5 Scheduler: Add protections for Yield bombing
In case of redundant yields, the scheduler will now idle the core for 
it's timeslice, in order to avoid continuously yielding the same thing 
over and over.
6 years ago
Fernando Sahmkow 82218c925a Kernel: Style and Corrections 6 years ago
Fernando Sahmkow 3a94e7ea33 Comment and reorganize the scheduler 6 years ago
Fernando Sahmkow b164d8ee53 Implement a new Core Scheduler 6 years ago
Lioncash e779686a76 kernel: Handle page table switching within MakeCurrentProcess()
Centralizes the page table switching to one spot, rather than making
calling code deal with it everywhere.
6 years ago
Lioncash 824b8e4086 kernel/scheduler: Remove unused parameter to AddThread()
This was made unused in b404fcdf14, but
the parameter itself wasn't removed.
6 years ago
Lioncash cb805f45ae kernel/scheduler: Use deduction guides on mutex locks
Since C++17, we no longer need to explicitly specify the type of the
mutex within the lock_guard. The type system can now deduce these with
deduction guides.
6 years ago
Fernando Sahmkow db42bcb306 Fixes and corrections on formatting. 6 years ago
Fernando Sahmkow dde0814837 Use MultiLevelQueue instead of old ThreadQueueList 6 years ago
bunnei 93da8e0abf core: Move PageTable struct into Common. 6 years ago
Lioncash c892cf01fa kernel/thread: Migrate WaitCurrentThread_Sleep into the Thread interface
Rather than make a global accessor for this sort of thing. We can make
it a part of the thread interface itself. This allows getting rid of a
hidden global accessor in the kernel code.
6 years ago
Lioncash fad20213e6 kernel/scheduler: Pass in system instance in constructor
Avoids directly relying on the global system instance and instead makes
an arbitrary system instance an explicit dependency on construction.

This also allows removing dependencies on some global accessor functions
as well.
6 years ago
Lioncash bd983414f6 core_timing: Convert core timing into a class
Gets rid of the largest set of mutable global state within the core.
This also paves a way for eliminating usages of GetInstance() on the
System class as a follow-up.

Note that no behavioral changes have been made, and this simply extracts
the functionality into a class. This also has the benefit of making
dependencies on the core timing functionality explicit within the
relevant interfaces.
6 years ago
Lioncash 48d9d66dc5 core_timing: Rename CoreTiming namespace to Core::Timing
Places all of the timing-related functionality under the existing Core
namespace to keep things consistent, rather than having the timing
utilities sitting in its own completely separate namespace.
6 years ago
Zach Hilman ddf5903cd9 scheduler: Avoid manual Reschedule call
This will automatically occur anyway when PrepareReschedule is called
6 years ago
Zach Hilman b5af41a07b scheduler: Only work steal higher priority threads from other cores 6 years ago
Zach Hilman 3476830b26 svc: Avoid performance-degrading unnecessary reschedule 6 years ago
Zach Hilman 820d81b9a5 scheduler: Add explanations for YieldWith and WithoutLoadBalancing 6 years ago
Zach Hilman 409dcf0e0a svc: Implement yield types 0 and -1 6 years ago
Lioncash 6594853eb1 svc: Implement svcGetInfo command 0xF0000002
This retrieves:

if (curr_thread == handle_thread) {
   result = total_thread_ticks + (hardware_tick_count - last_context_switch_ticks);
} else if (curr_thread == handle_thread && sub_id == current_core_index) {
   result = hardware_tick_count - last_context_switch_ticks;
}
7 years ago
Lioncash 5c0408596f kernel/thread: Use a regular pointer for the owner/current process
There's no real need to use a shared pointer in these cases, and only
makes object management more fragile in terms of how easy it would be to
introduce cycles. Instead, just do the simple thing of using a regular
pointer. Much of this is just a hold-over from citra anyways.

It also doesn't make sense from a behavioral point of view for a
process' thread to prolong the lifetime of the process itself (the
process is supposed to own the thread, not the other way around).
7 years ago
Lioncash baed7e1fba kernel/thread: Make all instance variables private
Many of the member variables of the thread class aren't even used
outside of the class itself, so there's no need to make those variables
public. This change follows in the steps of the previous changes that
made other kernel types' members private.

The main motivation behind this is that the Thread class will likely
change in the future as emulation becomes more accurate, and letting
random bits of the emulator access data members of the Thread class
directly makes it a pain to shuffle around and/or modify internals.
Having all data members public like this also makes it difficult to
reason about certain bits of behavior without first verifying what parts
of the core actually use them.

Everything being public also generally follows the tendency for changes
to be introduced in completely different translation units that would
otherwise be better introduced as an addition to the Thread class'
public interface.
7 years ago
Lioncash cf9d6c6f52 kernel/process: Make data member variables private
Makes the public interface consistent in terms of how accesses are done
on a process object. It also makes it slightly nicer to reason about the
logic of the process class, as we don't want to expose everything to
external code.
7 years ago
Lioncash a58eefa7e4 kernel/scheduler: Take ARM_Interface instance by reference in the constructor
It doesn't make sense to allow a scheduler to be constructed around a
null pointer.
7 years ago
Lioncash 43e0d865fa core: Namespace all code in the arm subdirectory under the Core namespace
Gets all of these types and interfaces out of the global namespace.
7 years ago
Lioncash e850ff63bc scheduler: Make HaveReadyThreads() a const member function
This function doesn't modify instance state, so the const qualifier can
be added to it.
7 years ago
Lioncash a2304fad16 kernel: Remove unnecessary includes
Removes unnecessary direct dependencies in some headers and also gets
rid of indirect dependencies that were being relied on to be included.
7 years ago
bunnei fe2498a650
Merge pull request #751 from Subv/tpidr_el0
CPU: Save and restore the TPIDR_EL0 system register on every context switch
7 years ago
Subv d84eb9dac6 CPU: Save and restore the TPIDR_EL0 system register on every context switch.
Note that there's currently a dynarmic bug preventing this register from being written.
7 years ago
Lioncash dbfe82773d thread: Convert ThreadStatus into an enum class
Makes the thread status strongly typed, so implicit conversions can't
happen. It also makes it easier to catch mistakes at compile time.
7 years ago
Lioncash 46458e7284 core/memory, core/hle/kernel: Use std::move where applicable
Avoids pointless copies
7 years ago
MerryMage 56cc1c11ec scheduler: Clear exclusive state when switching contexts 7 years ago
James Rowe 638956aa81 Rename logging macro back to LOG_* 7 years ago
bunnei 91af2f94e8 scheduler: Protect scheduling functions with a global mutex. 7 years ago