aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
AgeCommit message (Collapse)Author
2018-10-15core_cpu: Make Cpu scheduler instances unique_ptrs instead of shared_ptrsLioncash
2018-10-12thread: Remove unnecessary memset from ResetThreadContext()Lioncash
Regular value initialization is adequate here for zeroing out data. It also has the benefit of not invoking undefined behavior if a non-trivial type is ever added to the struct for whatever reason.
2018-10-10kernel/thread: Use a regular pointer for the owner/current processLioncash
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-05thread: Make the scheduler pointer a regular pointerbalika011
Conceptually, it doesn't make sense for a thread to be able to persist the lifetime of a scheduler. A scheduler should be taking care of the threads; the threads should not be taking care of the scheduler. If the threads outlive the scheduler (or we simply don't actually terminate/shutdown the threads), then it should be considered a bug that we need to fix. Attributing this to balika011, as they opened #1317 to attempt to fix this in a similar way, but my refactoring of the kernel code caused quite a few conflicts.
2018-10-04kernel/thread: Make all instance variables privateLioncash
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-09-30kernel/process: Make data member variables privateLioncash
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-24memory: Dehardcode the use of fixed memory range constantsLioncash
The locations of these can actually vary depending on the address space layout, so we shouldn't be using these when determining where to map memory or be using them as offsets for calculations. This keeps all the memory ranges flexible and malleable based off of the virtual memory manager instance state.
2018-09-21thread/process: Move TLS slot marking/freeing to the process classLioncash
Allows making several members of the process class private, it also avoids going through Core::CurrentProcess() just to retrieve the owning process.
2018-09-20kernel/thread: Use owner_process when setting the page table in ↵Lioncash
SetupMainThread() The owning process of a thread is required to exist before the thread, so we can enforce this API-wise by using a reference. We can also avoid the reliance on the system instance by using that parameter to access the page table that needs to be set.
2018-09-18arm_interface: Remove ARM11-isms from the CPU interfaceLioncash
This modifies the CPU interface to more accurately match an AArch64-supporting CPU as opposed to an ARM11 one. Two of the methods don't even make sense to keep around for this interface, as Adv Simd is used, rather than the VFP in the primary execution state. This is essentially a modernization change that should have occurred from the get-go.
2018-09-15Port #4182 from Citra: "Prefix all size_t with std::"fearlessTobi
2018-09-12kernel/errors: Correct error codes for invalid thread priority and invalid ↵Lioncash
processor ID
2018-08-31core/core: Replace includes with forward declarations where applicableLioncash
The follow-up to e2457418dae19b889b2ad85255bb95d4cd0e4bff, which replaces most of the includes in the core header with forward declarations. This makes it so that if any of the headers the core header was previously including change, then no one will need to rebuild the bulk of the core, due to core.h being quite a prevalent inclusion. This should make turnaround for changes much faster for developers.
2018-08-28kernel: Eliminate kernel global stateLioncash
As means to pave the way for getting rid of global state within core, This eliminates kernel global state by removing all globals. Instead this introduces a KernelCore class which acts as a kernel instance. This instance lives in the System class, which keeps its lifetime contained to the lifetime of the System class. This also forces the kernel types to actually interact with the main kernel instance itself instead of having transient kernel state placed all over several translation units, keeping everything together. It also has a nice consequence of making dependencies much more explicit. This also makes our initialization a tad bit more correct. Previously we were creating a kernel process before the actual kernel was initialized, which doesn't really make much sense. The KernelCore class itself follows the PImpl idiom, which allows keeping all the implementation details sealed away from everything else, which forces the use of the exposed API and allows us to avoid any unnecessary inclusions within the main kernel header.
2018-08-24core: Namespace all code in the arm subdirectory under the Core namespaceLioncash
Gets all of these types and interfaces out of the global namespace.
2018-08-13Core::CoreTiming: add UnscheduleEventThreadsafeB3n30
2018-08-12Merge pull request #1042 from Subv/racesbunnei
Fixed a bunch of race conditions when running in multicore mode.
2018-08-12Kernel/Threads: Lock the HLE mutex when executing the wakeup callback.Subv
Another thread might be in the middle of a reschedule, thus altering the state of the schedulers.
2018-08-12Kernel/Thread: Always use the threadsafe option when scheduling wakeups.Subv
WakeAfterDelay might be called from any host thread, so err on the side of caution and use the thread-safe CoreTiming::ScheduleEventThreadsafe. Note that CoreTiming is still far from thread-safe, there may be more things we have to work on for it to be up to par with what we want.
2018-08-12Kernel/Mutex: Don't duplicate threads in the mutex waiter list.Subv
Exit from AddMutexWaiter early if the thread is already waiting for a mutex owned by the owner thread. This accounts for the possibility of a thread that is waiting on a condition variable being awakened twice in a row. Also added more validation asserts. This should fix one of the random crashes in Breath Of The Wild.
2018-08-03kernel/thread: Fix potential crashes introduced in ↵Lioncash
26de4bb521b1ace7af76eff4f6956cb23ac0d58c This amends cases where crashes can occur that were missed due to the odd way the previous code was set up (using 3DS memory regions that don't exist).
2018-08-03core/memory: Get rid of 3DS leftoversLioncash
Removes leftover code from citra that isn't needed.
2018-08-03Merge pull request #894 from lioncash/objectbunnei
kernel: Move object class to its own source files
2018-08-02kernel/thread: Make GetFreeThreadLocalSlot()'s loop indices size_tLioncash
Avoids using a u32 to compare against a range of size_t, which can be a source of warnings. While we're at it, compress a std::tie into a structured binding.
2018-08-02kernel/thread: Make GetFreeThreadLocalSlot() reference parameter a const ↵Lioncash
reference This function only reads the data being referenced, it doesn't modify it, so we can turn the reference into a const reference.
2018-08-02kernel/thread: Make GetFreeThreadLocalSlot() internally linkedLioncash
This function isn't used outside of this translation unit, so we can make it internally linked.
2018-08-01kernel: Move object class to its own source filesLioncash
General moving to keep kernel object types separate from the direct kernel code. Also essentially a preliminary cleanup before eliminating global kernel state in the kernel code.
2018-07-31kernel: Remove unnecessary includesLioncash
Removes unnecessary direct dependencies in some headers and also gets rid of indirect dependencies that were being relied on to be included.
2018-07-24core_timing: Split off utility functions into core_timing_utilMerryMage
2018-07-21Merge pull request #751 from Subv/tpidr_el0bunnei
CPU: Save and restore the TPIDR_EL0 system register on every context switch
2018-07-20CPU: Save and restore the TPIDR_EL0 system register on every context switch.Subv
Note that there's currently a dynarmic bug preventing this register from being written.
2018-07-19thread: Convert ThreadStatus into an enum classLioncash
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-18Merge pull request #690 from lioncash/movebunnei
core/memory, core/hle/kernel: Use std::move where applicable
2018-07-18core/memory, core/hle/kernel: Use std::move where applicableLioncash
Avoids pointless copies
2018-07-18core: Don't construct instance of Core::System, just to access its live instanceLioncash
This would result in a lot of allocations and related object construction, just to toss it all away immediately after the call. These are definitely not intentional, and it was intended that all of these should have been accessing the static function GetInstance() through the name itself, not constructed instances.
2018-07-02Update clang formatJames Rowe
2018-07-02Rename logging macro back to LOG_*James Rowe
2018-06-21Kernel/Arbiters: Implement WaitForAddressMichael Scire
2018-06-02Kernel/Threads: A thread waking up by timeout from a WaitProcessWideKey may ↵Subv
already have an assigned lock owner. This situation may happen like so: Thread 1 with low priority calls WaitProcessWideKey with timeout. Thread 2 with high priority calls WaitProcessWideKey without timeout. Thread 3 calls SignalProcessWideKey - Thread 2 acquires the lock and awakens. - Thread 1 can't acquire the lock and is put to sleep with the lock owner being Thread 2. Thread 1's timeout expires, with the lock owner still being set to Thread 2.
2018-05-30Kernel/Thread: Corrected a typo that caused the affinity mask to never be ↵Subv
changed.
2018-05-30Kernel/Thread: Corrected a typo in an assert about the processor id.Subv
2018-05-10thread: Rename mask to affinity_masks.bunnei
2018-05-10thread: Support core change on ResumeFromWait and improve ChangeCore.bunnei
2018-05-10thread: Initialize ideal_core and mask members.bunnei
2018-05-10threading: Reschedule only on cores that are necessary.bunnei
2018-05-10thread: Implement ChangeCore function.bunnei
2018-05-10core: Implement multicore support.bunnei
2018-04-30core_timing: Namespace all functions and constants in core_timing's headerLioncash
All of these variables and functions are related to timings and should be within the namespace.
2018-04-27general: Convert assertion macros over to be fmt-compatibleLioncash
2018-04-25kernel: Migrate logging macros to fmt-compatible onesLioncash