aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* kernel: Replace usage of boost::intrusive_ptr with std::shared_ptr for ↵bunnei2019-11-241-19/+20
| | | | | | | | 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.
* Merge pull request #3114 from FernandoS27/cond-varbunnei2019-11-231-0/+8
|\ | | | | Kernel: Correct behavior of Condition Variables to be more similar to real hardware.
| * Kernel: Correct behavior of Condition Variables to be more similar to real ↵Fernando Sahmkow2019-11-211-0/+8
| | | | | | | | | | | | | | | | | | hardware. This commit ensures cond var threads act exactly as they do in the real console. The original implementation uses an RBTree and the behavior of cond var threads is that at the same priority level they act like a FIFO.
* | Merge pull request #3130 from FernandoS27/cancel-syncbunnei2019-11-231-2/+5
|\ \ | |/ |/| Kernel: Correct Cancel Synchronization.
| * Kernel: Correct Cancel Synchronization.Fernando Sahmkow2019-11-161-2/+5
| | | | | | | | | | | | This commit corrects the behavior of cancel synchronization when the thread is running/ready and ensures the next wait is cancelled as it's suppose to.
* | kernel: Resolve sign conversion warningsLioncash2019-11-121-30/+18
|/ | | | | | | | | 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.
* Kernel Thread: Cleanup THREADPROCESSORID_DONT_UPDATE.Fernando Sahmkow2019-10-151-1/+1
|
* Kernel: Address Feedback 2Fernando Sahmkow2019-10-151-3/+3
|
* Kernel: Clang FormatFernando Sahmkow2019-10-151-4/+4
|
* Kernel: Reverse global accessor removal.Fernando Sahmkow2019-10-151-8/+8
|
* Kernel: Address Feedback.Fernando Sahmkow2019-10-151-9/+8
|
* Kernel_Thread: Eliminate most global accessors.Fernando Sahmkow2019-10-151-11/+11
|
* Kernel: Correct Paused schedulingFernando Sahmkow2019-10-151-3/+1
|
* Kernel: Corrections to Wait Objects clearing in which a thread could still ↵Fernando Sahmkow2019-10-151-0/+1
| | | | be signalled after a timeout or a cancel.
* Scheduler: Add protections for Yield bombingFernando Sahmkow2019-10-151-6/+6
| | | | | | 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.
* Kernel: Style and CorrectionsFernando Sahmkow2019-10-151-24/+30
|
* Addapt thread class to the new SchedulerFernando Sahmkow2019-10-151-59/+183
|
* kernel/process: Decouple TLS handling from threadsLioncash2019-07-031-2/+2
| | | | | | | | | | | Extracts out all of the thread local storage management from thread instances themselves and makes the owning process handle the management of the memory. This brings the memory management slightly more in line with how the kernel handles these allocations. Furthermore, this also makes the TLS page management a little more readable compared to the lingering implementation that was carried over from Citra.
* Core_Timing: Make core_timing threadsafe by default.Fernando Sahmkow2019-06-161-3/+3
| | | | | | The old implementation had faulty Threadsafe methods where events could be missing. This implementation unifies unsafe/safe methods and makes core timing thread safe overall.
* core/core_timing_util: Use std::chrono types for specifying time unitsLioncash2019-06-041-2/+2
| | | | | Makes the interface more type-safe and consistent in terms of return values.
* kernel/thread: Unify wait synchronization typesLioncash2019-04-171-3/+2
| | | | | | | | | | | | | | | | This is a holdover from Citra, where the 3DS has both WaitSynchronization1 and WaitSynchronizationN. The switch only has one form of wait synchronizing (literally WaitSynchonization). This allows us to throw out code that doesn't apply at all to the Switch kernel. Because of this unnecessary dichotomy within the wait synchronization utilities, we were also neglecting to properly handle waiting on multiple objects. While we're at it, we can also scrub out any lingering references to WaitSynchronization1/WaitSynchronizationN in comments, and change them to WaitSynchronization (or remove them if the mention no longer applies).
* kernel/svc: Migrate svcCancelSynchronization behavior to a thread functionLioncash2019-04-171-0/+6
| | | | | | | The actual behavior of this function is slightly more complex than what we're currently doing within the supervisor call. To avoid dumping most of this behavior in the supervisor call itself, we can migrate this to another function.
* kernel/thread: Remove BoostPriority()Lioncash2019-04-151-5/+0
| | | | | This is a holdover from Citra that currently remains unused, so it can be removed from the Thread interface.
* Merge pull request #2314 from lioncash/constbunnei2019-04-031-6/+6
|\ | | | | kernel/thread: Minor interface cleanup
| * kernel/thread: Make AllWaitObjectsReady() a const qualified member functionLioncash2019-04-011-1/+1
| | | | | | | | | | | | Now that ShouldWait() is a const qualified member function, this one can be made const qualified as well, since it can handle passing a const qualified this pointer to ShouldWait().
| * kernel/wait_object: Make ShouldWait() take thread members by pointer-to-constLioncash2019-04-011-1/+1
| | | | | | | | | | Given this is intended as a querying function, it doesn't make sense to allow the implementer to modify the state of the given thread.
| * kernel/thread: Avoid sign conversion within GetCommandBufferAddress()Lioncash2019-04-011-2/+2
| | | | | | | | | | | | | | | | | | | | Previously this was performing a u64 + int sign conversion. When dealing with addresses, we should generally be keeping the arithmetic in the same signedness type. This also gets rid of the static lifetime of the constant, as there's no need to make a trivial type like this potentially live for the entire duration of the program.
| * kernel/thread: Make parameter of GetWaitObjectIndex() const qualifiedLioncash2019-04-011-2/+2
| | | | | | | | | | The pointed to member is never actually modified, so it can be made const.
* | kernel/svc: Implement svcGetThreadListLioncash2019-04-021-0/+4
|/ | | | | | | | | | | | | Similarly like svcGetProcessList, this retrieves the list of threads from the current process. In the kernel itself, a process instance maintains a list of threads, which are used within this function. Threads are registered to a process' thread list at thread initialization, and unregistered from the list upon thread destruction (if said thread has a non-null owning process). We assert on the debug event case, as we currently don't implement kernel debug objects.
* kernel/scheduler: Remove unused parameter to AddThread()Lioncash2019-03-301-2/+2
| | | | | This was made unused in 1913519836ce65b1b4a9e117b11d7bbf4a79e52d, but the parameter itself wasn't removed.
* Merge pull request #2266 from FernandoS27/arbitrationbunnei2019-03-281-0/+1
|\ | | | | Kernel: Fixes to Arbitration and SignalProcessWideKey Management
| * Add CondVar Thread State.Fernando Sahmkow2019-03-191-0/+1
| |
* | Fix crash caused by 2238.Fernando Sahmkow2019-03-191-1/+2
|/
* Merge pull request #2238 from lioncash/threadbunnei2019-03-171-19/+33
|\ | | | | kernel/thread: Amend conditional test and assignment within UpdatePriority()
| * kernel/thread: Expand documentation of nominal_priority and current_priorityLioncash2019-03-151-1/+3
| | | | | | | | | | Aims to disambiguate why each priority instance exists a little bit. While we're at it, also add an explanatory comment to UpdatePriority().
| * kernel/thread: Make bracing consistent within UpdatePriority()Lioncash2019-03-151-2/+4
| |
| * kernel/thread: Amend condition within UpdatePriority()Lioncash2019-03-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This condition was checking against the nominal thread priority, whereas the kernel itself checks against the current priority instead. We were also assigning the nominal priority, when we should be assigning current_priority, which takes priority inheritance into account. This can lead to the incorrect priority being assigned to a thread. Given we recursively update the relevant threads, we don't need to go through the whole mutex waiter list. This matches what the kernel does as well (only accessing the first entry within the waiting list).
| * kernel/thread: Maintain priority ordering of added mutex waiting threadsLioncash2019-03-151-14/+24
| | | | | | | | | | The kernel keeps the internal waiting list ordered by priority. This is trivial to do with std::find_if followed by an insertion.
* | kernel/thread: Actually remove the definition of ExitCurrentThread()Lioncash2019-03-161-6/+0
| | | | | | | | | | | | This was intended to be removed in 0032bede5a880a44bffcb702eb8fe858c214dc39, but I guess I forgot to actually save the file like a dingus.
* | kernel/thread: Migrate WaitCurrentThread_Sleep into the Thread interfaceLioncash2019-03-151-5/+8
|/ | | | | | 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.
* kernel/thread: Remove obsolete TODO in Create()Lioncash2019-03-051-2/+0
| | | | This is a TODO carried over from Citra that doesn't apply here.
* core_timing: Convert core timing into a classLioncash2019-02-151-8/+11
| | | | | | | | | | | 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.
* core_timing: Rename CoreTiming namespace to Core::TimingLioncash2019-02-121-6/+7
| | | | | | 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.
* kernel/thread: Move process thread initialization into process.cppLioncash2018-12-271-24/+0
| | | | | | | | | | This function isn't a general purpose function that should be exposed to everything, given it's specific to initializing the main thread for a Process instance. Given that, it's a tad bit more sensible to place this within process.cpp, which keeps it visible only to the code that actually needs it.
* Merge pull request #1849 from encounter/svcSetThreadActivitybunnei2018-12-261-1/+23
|\ | | | | svc: Implement SetThreadActivity (thread suspension)
| * svc: Implement SetThreadActivity (thread suspension)Luke Street2018-12-041-1/+23
| |
* | kernel/thread: Set default fpcrMerryMage2018-12-181-0/+3
|/
* 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.