Commit Graph

53 Commits

Author SHA1 Message Date
Fernando Sahmkow
647ad8ce9b 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.
2019-12-05 18:08:59 -04:00
bunnei
467d60256b 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.
2019-11-24 20:15:51 -05:00
Lioncash
a625854117 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.
2019-11-12 07:55:39 -05:00
Lioncash
9b94487ba4 scheduler: Mark parameter of AskForReselectionOrMarkRedundant() as const
This is only compared against, so it can be made const.
2019-10-27 23:35:50 -04:00
Lioncash
9c56320168 scheduler: Silence sign conversion warnings 2019-10-27 22:44:52 -04:00
Lioncash
ba2899eb10 scheduler: Initialize class members directly where applicable
Reduces the overall amount of code.
2019-10-27 22:13:55 -04:00
Lioncash
e5bda810bf scheduler: Amend documentation comments
Adjusts the formatting of a few of the comments an ensures they get
recognized as proper Doxygen comments.
2019-10-27 22:12:32 -04:00
Fernando Sahmkow
758c107ef1 Kernel: Clang Format 2019-10-15 11:55:27 -04:00
Fernando Sahmkow
0959db9a4b Kernel: Address Feedback. 2019-10-15 11:55:25 -04:00
Fernando Sahmkow
c765a16a9a Kernel Scheduler: Make sure the global scheduler shutdowns correctly. 2019-10-15 11:55:24 -04:00
Fernando Sahmkow
36d2e3d56a Kernel: Clang Format 2019-10-15 11:55:17 -04:00
Fernando Sahmkow
3818e875cd Kernel: Remove global system accessor from WaitObject 2019-10-15 11:55:16 -04:00
Fernando Sahmkow
1a32563ff4 Scheduler: Implement Yield Count and Core migration on Thread Preemption. 2019-10-15 11:55:16 -04:00
Fernando Sahmkow
514cb21351 Scheduler: Corrections to YieldAndBalanceLoad and Yield bombing protection. 2019-10-15 11:55:15 -04:00
Fernando Sahmkow
e5f4011bae Kernel: Initial implementation of thread preemption. 2019-10-15 11:55:14 -04:00
Fernando Sahmkow
69d7d41328 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.
2019-10-15 11:55:13 -04:00
Fernando Sahmkow
5194851422 Kernel: Style and Corrections 2019-10-15 11:55:12 -04:00
Fernando Sahmkow
db32944ff4 Comment and reorganize the scheduler 2019-10-15 11:55:11 -04:00
Fernando Sahmkow
2de90f56cf Implement a new Core Scheduler 2019-10-15 11:55:04 -04:00
Lioncash
6fff10e9de kernel: Handle page table switching within MakeCurrentProcess()
Centralizes the page table switching to one spot, rather than making
calling code deal with it everywhere.
2019-04-07 01:12:54 -04:00
Lioncash
724feab20d kernel/scheduler: Remove unused parameter to AddThread()
This was made unused in b404fcdf14, but
the parameter itself wasn't removed.
2019-03-30 05:29:33 -04:00
Lioncash
c2f2ee4a50 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.
2019-03-30 05:28:43 -04:00
Fernando Sahmkow
2fc532c6ad Fixes and corrections on formatting. 2019-03-27 14:49:43 -04:00
Fernando Sahmkow
e0cbdc1752 Use MultiLevelQueue instead of old ThreadQueueList 2019-03-27 14:34:32 -04:00
bunnei
2433c449d4 core: Move PageTable struct into Common. 2019-03-16 22:05:40 -04:00
Lioncash
3bc69d1af2 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.
2019-03-15 23:58:31 -04:00
Lioncash
25ba4d0ba5 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.
2019-03-04 17:01:37 -05:00
Lioncash
2a4e34bb72 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.
2019-02-15 21:50:25 -05:00
Lioncash
8b6005bca5 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.
2019-02-12 12:42:17 -05:00
Zach Hilman
c7d0ea756e scheduler: Avoid manual Reschedule call
This will automatically occur anyway when PrepareReschedule is called
2018-12-03 21:22:09 -05:00
Zach Hilman
8908fa3bb7 scheduler: Only work steal higher priority threads from other cores 2018-12-03 17:29:30 -05:00
Zach Hilman
be6c26bb23 svc: Avoid performance-degrading unnecessary reschedule 2018-12-02 00:44:40 -05:00
Zach Hilman
52696a99c1 scheduler: Add explanations for YieldWith and WithoutLoadBalancing 2018-11-22 00:33:53 -05:00
Zach Hilman
f998b78fed svc: Implement yield types 0 and -1 2018-11-18 23:44:19 -05:00
Lioncash
faba20226e 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;
}
2018-10-26 12:49:11 -04:00
Lioncash
7e52fbb22b 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).
2018-10-10 02:04:55 -04:00
Lioncash
66f41814dc 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.
2018-10-04 00:14:15 -04:00
Lioncash
7bebd9fcc5 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.
2018-09-30 02:30:01 -04:00
Lioncash
417235c2eb 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.
2018-09-25 16:00:17 -04:00
Lioncash
577e8d87cf core: Namespace all code in the arm subdirectory under the Core namespace
Gets all of these types and interfaces out of the global namespace.
2018-08-24 21:50:39 -04:00
Lioncash
fa4ef48a68 scheduler: Make HaveReadyThreads() a const member function
This function doesn't modify instance state, so the const qualifier can
be added to it.
2018-08-12 12:55:58 -04:00
Lioncash
2811d57c6e 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.
2018-07-31 10:15:17 -04:00
bunnei
e732a782ac Merge pull request #751 from Subv/tpidr_el0
CPU: Save and restore the TPIDR_EL0 system register on every context switch
2018-07-21 10:48:30 -07:00
Subv
00f17a92ba 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.
2018-07-20 19:57:45 -05:00
Lioncash
ada731907a 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.
2018-07-19 22:08:56 -04:00
Lioncash
3bac924c46 core/memory, core/hle/kernel: Use std::move where applicable
Avoids pointless copies
2018-07-18 19:34:31 -04:00
MerryMage
93713fc291 scheduler: Clear exclusive state when switching contexts 2018-07-16 11:24:00 +01:00
James Rowe
847a518200 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
bunnei
b626902984 scheduler: Protect scheduling functions with a global mutex. 2018-05-10 19:34:52 -04:00
Lioncash
29210b602c kernel: Migrate logging macros to fmt-compatible ones 2018-04-25 20:32:09 -04:00