aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
Commit message (Collapse)AuthorAgeFilesLines
* kernel/thread: Deduplicate scheduler switching codeLioncash2018-11-141-37/+11
| | | | | The code in both places was the same verbatim, so we can extract it to a function to deduplicate the logic.
* global: Use std::optional instead of boost::optional (#1578)Frederic L2018-10-301-4/+4
| | | | | | | | | | | | | | | | * get rid of boost::optional * Remove optional references * Use std::reference_wrapper for optional references * Fix clang format * Fix clang format part 2 * Adressed feedback * Fix clang format and MacOS build
* kernel/process: Make the handle table per-processLioncash2018-10-201-1/+1
| | | | | | | | In the kernel, there isn't a singular handle table that everything gets tossed into or used, rather, each process gets its own handle table that it uses. This currently isn't an issue for us, since we only execute one process at the moment, but we may as well get this out of the way so it's not a headache later on.
* core_cpu: Make Cpu scheduler instances unique_ptrs instead of shared_ptrsLioncash2018-10-151-8/+8
|
* thread: Remove unnecessary memset from ResetThreadContext()Lioncash2018-10-121-4/+1
| | | | | | 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.
* kernel/thread: Use a regular pointer for the owner/current processLioncash2018-10-101-4/+4
| | | | | | | | | | | 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).
* thread: Make the scheduler pointer a regular pointerbalika0112018-10-051-3/+3
| | | | | | | | | | | | | | 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.
* kernel/thread: Make all instance variables privateLioncash2018-10-041-4/+28
| | | | | | | | | | | | | | | | | | | | 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.
* kernel/process: Make data member variables privateLioncash2018-09-301-2/+2
| | | | | | | 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.
* memory: Dehardcode the use of fixed memory range constantsLioncash2018-09-241-1/+2
| | | | | | | | 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.
* thread/process: Move TLS slot marking/freeing to the process classLioncash2018-09-211-56/+2
| | | | | | Allows making several members of the process class private, it also avoids going through Core::CurrentProcess() just to retrieve the owning process.
* kernel/thread: Use owner_process when setting the page table in ↵Lioncash2018-09-201-3/+3
| | | | | | | | | 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.
* arm_interface: Remove ARM11-isms from the CPU interfaceLioncash2018-09-181-2/+2
| | | | | | | | | 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.
* Port #4182 from Citra: "Prefix all size_t with std::"fearlessTobi2018-09-151-1/+1
|
* kernel/errors: Correct error codes for invalid thread priority and invalid ↵Lioncash2018-09-121-2/+2
| | | | processor ID
* core/core: Replace includes with forward declarations where applicableLioncash2018-08-311-1/+2
| | | | | | | | | | | The follow-up to 88597535d629ea9a265f8bf0f00a9ce4dd5dc218, 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.
* kernel: Eliminate kernel global stateLioncash2018-08-281-101/+18
| | | | | | | | | | | | | | | | | | | | | | 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.
* core: Namespace all code in the arm subdirectory under the Core namespaceLioncash2018-08-241-2/+2
| | | | Gets all of these types and interfaces out of the global namespace.
* Core::CoreTiming: add UnscheduleEventThreadsafeB3n302018-08-131-1/+1
|
* Merge pull request #1042 from Subv/racesbunnei2018-08-121-2/+9
|\ | | | | Fixed a bunch of race conditions when running in multicore mode.
| * Kernel/Threads: Lock the HLE mutex when executing the wakeup callback.Subv2018-08-121-0/+5
| | | | | | | | Another thread might be in the middle of a reschedule, thus altering the state of the schedulers.
| * Kernel/Thread: Always use the threadsafe option when scheduling wakeups.Subv2018-08-121-2/+4
| | | | | | | | | | | | 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.
* | Kernel/Mutex: Don't duplicate threads in the mutex waiter list.Subv2018-08-121-0/+21
|/ | | | | | | | | | 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.
* kernel/thread: Fix potential crashes introduced in ↵Lioncash2018-08-031-0/+11
| | | | | | | | 3bcf090d37e20e0096954c478179487d071bb37b 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).
* core/memory: Get rid of 3DS leftoversLioncash2018-08-031-31/+2
| | | | Removes leftover code from citra that isn't needed.
* Merge pull request #894 from lioncash/objectbunnei2018-08-031-1/+1
|\ | | | | kernel: Move object class to its own source files
| * kernel: Move object class to its own source filesLioncash2018-08-011-1/+1
| | | | | | | | | | | | 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.
* | kernel/thread: Make GetFreeThreadLocalSlot()'s loop indices size_tLioncash2018-08-021-8/+5
| | | | | | | | | | | | 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.
* | kernel/thread: Make GetFreeThreadLocalSlot() reference parameter a const ↵Lioncash2018-08-021-1/+2
| | | | | | | | | | | | | | reference This function only reads the data being referenced, it doesn't modify it, so we can turn the reference into a const reference.
* | kernel/thread: Make GetFreeThreadLocalSlot() internally linkedLioncash2018-08-021-1/+1
|/ | | | | This function isn't used outside of this translation unit, so we can make it internally linked.
* kernel: Remove unnecessary includesLioncash2018-07-311-2/+4
| | | | | Removes unnecessary direct dependencies in some headers and also gets rid of indirect dependencies that were being relied on to be included.
* core_timing: Split off utility functions into core_timing_utilMerryMage2018-07-241-0/+1
|
* Merge pull request #751 from Subv/tpidr_el0bunnei2018-07-211-0/+1
|\ | | | | CPU: Save and restore the TPIDR_EL0 system register on every context switch
| * CPU: Save and restore the TPIDR_EL0 system register on every context switch.Subv2018-07-201-0/+1
| | | | | | | | Note that there's currently a dynarmic bug preventing this register from being written.
* | thread: Convert ThreadStatus into an enum classLioncash2018-07-191-24/+23
|/ | | | | Makes the thread status strongly typed, so implicit conversions can't happen. It also makes it easier to catch mistakes at compile time.
* Merge pull request #690 from lioncash/movebunnei2018-07-181-1/+1
|\ | | | | core/memory, core/hle/kernel: Use std::move where applicable
| * core/memory, core/hle/kernel: Use std::move where applicableLioncash2018-07-181-1/+1
| | | | | | | | Avoids pointless copies
* | core: Don't construct instance of Core::System, just to access its live instanceLioncash2018-07-181-6/+6
|/ | | | | | | | | 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.
* Update clang formatJames Rowe2018-07-021-1/+1
|
* Rename logging macro back to LOG_*James Rowe2018-07-021-5/+5
|
* Kernel/Arbiters: Implement WaitForAddressMichael Scire2018-06-211-0/+6
|
* Kernel/Threads: A thread waking up by timeout from a WaitProcessWideKey may ↵Subv2018-06-021-2/+5
| | | | | | | | | | | | 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.
* Kernel/Thread: Corrected a typo that caused the affinity mask to never be ↵Subv2018-05-301-2/+2
| | | | changed.
* Kernel/Thread: Corrected a typo in an assert about the processor id.Subv2018-05-301-1/+1
|
* thread: Rename mask to affinity_masks.bunnei2018-05-101-2/+2
|
* thread: Support core change on ResumeFromWait and improve ChangeCore.bunnei2018-05-101-37/+68
|
* thread: Initialize ideal_core and mask members.bunnei2018-05-101-0/+2
|
* threading: Reschedule only on cores that are necessary.bunnei2018-05-101-1/+1
|
* thread: Implement ChangeCore function.bunnei2018-05-101-1/+52
|
* core: Implement multicore support.bunnei2018-05-101-8/+8
|