summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/thread.cpp (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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 processor IDLioncash2018-09-121-2/+2
|
* core/core: Replace includes with forward declarations where applicableLioncash2018-08-311-1/+2
| | | | | | | | | | | 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.
* kernel: Eliminate kernel global stateLioncash2018-08-291-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-251-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-131-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-131-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-131-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 26de4bb521b1ace7af76eff4f6956cb23ac0d58cLioncash2018-08-041-0/+11
| | | | | | 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-021-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 referenceLioncash2018-08-021-1/+2
| | | | | | | | | | 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-211-0/+1
| | | | | | | | Note that there's currently a dynarmic bug preventing this register from being written.
* | thread: Convert ThreadStatus into an enum classLioncash2018-07-201-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-191-1/+1
|\ | | | | core/memory, core/hle/kernel: Use std::move where applicable
| * core/memory, core/hle/kernel: Use std::move where applicableLioncash2018-07-191-1/+1
| | | | | | | | Avoids pointless copies
* | core: Don't construct instance of Core::System, just to access its live instanceLioncash2018-07-191-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-031-1/+1
|
* Rename logging macro back to LOG_*James Rowe2018-07-031-5/+5
|
* Kernel/Arbiters: Implement WaitForAddressMichael Scire2018-06-211-0/+6
|
* Kernel/Threads: A thread waking up by timeout from a WaitProcessWideKey may already have an assigned lock owner.Subv2018-06-021-2/+5
| | | | | | | | | | 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 changed.Subv2018-05-311-2/+2
|
* 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-111-2/+2
|
* thread: Support core change on ResumeFromWait and improve ChangeCore.bunnei2018-05-111-37/+68
|
* thread: Initialize ideal_core and mask members.bunnei2018-05-111-0/+2
|
* threading: Reschedule only on cores that are necessary.bunnei2018-05-111-1/+1
|
* thread: Implement ChangeCore function.bunnei2018-05-111-1/+52
|
* core: Implement multicore support.bunnei2018-05-111-8/+8
|
* core_timing: Namespace all functions and constants in core_timing's headerLioncash2018-04-301-1/+2
| | | | All of these variables and functions are related to timings and should be within the namespace.
* general: Convert assertion macros over to be fmt-compatibleLioncash2018-04-271-2/+2
|
* kernel: Migrate logging macros to fmt-compatible onesLioncash2018-04-261-7/+8
|
* Kernel: Implemented mutex priority inheritance.Subv2018-04-231-2/+39
| | | | | | | Verified with a hwtest and implemented based on reverse engineering. Thread A's priority will get bumped to the highest priority among all the threads that are waiting for a mutex that A holds. Once A releases the mutex and ownership is transferred to B, A's priority will return to normal and B's priority will be bumped.
* Kernel: Remove unused ConditionVariable class.Subv2018-04-211-9/+0
|
* Kernel: Remove old and unused Mutex code.Subv2018-04-211-3/+0
|
* Kernel: Corrected the implementation of svcArbitrateLock and svcArbitrateUnlock.Subv2018-04-211-1/+12
| | | | | | | | | | Switch mutexes are no longer kernel objects, they are managed in userland and only use the kernel to handle the contention case. Mutex addresses store a special flag value (0x40000000) to notify the guest code that there are still some threads waiting for the mutex to be released. This flag is updated when a thread calls ArbitrateUnlock. TODO: * Fix svcWaitProcessWideKey * Fix svcSignalProcessWideKey * Remove the Mutex class.
* memory: Fix stack region.bunnei2018-03-311-1/+1
|
* thread: Add THREADSTATUS_WAIT_HLE_EVENT, remove THREADSTATUS_WAIT_ARB.bunnei2018-03-191-18/+3
|
* kernel: Move stack region outside of application heap.bunnei2018-03-161-1/+1
|
* MemoryState: Add additional memory states and improve naming.bunnei2018-03-161-1/+1
|
* core: Move process creation out of global state.bunnei2018-03-141-2/+2
|
* thread: Clear the process list on shutdown.Jules Blok2018-02-271-1/+3
|
* kernel: Use Scheduler class for threading.bunnei2018-02-181-155/+14
|
* kernel: Remove unused address_arbiter code.bunnei2018-02-181-34/+0
|
* Kernel/IPC: Add a small delay after each SyncRequest to prevent thread starvation.Subv2018-02-181-0/+1
| | | | | | | | Ported from citra PR #3091 The delay specified here is from a Nintendo 3DS, and should be measured in a Nintendo Switch. This change is enough to prevent Puyo Puyo Tetris's main thread starvation.
* thread: Silence formatting specifier warningsLioncash2018-02-141-2/+3
|
* Kernel: Allow chaining WaitSynchronization calls inside a wakeup callback.Subv2018-01-091-8/+17
|
* CoreTiming: Reworked CoreTiming (cherry-picked from Citra #3119)B3n302018-01-091-3/+2
| | | | * CoreTiming: New CoreTiming; Add Test for CoreTiming
* arm: Remove SkyEye/Dyncom code that is ARMv6-only.bunnei2018-01-031-4/+2
|
* thread: Keep track of the initially created handle.bunnei2017-12-311-1/+2
| | | | This is kinda crufty, but we need it for now to update guest state variables.
* thread: Main thread should set thread handle to reg 1.bunnei2017-12-301-1/+4
|
* thread: Remove THUMB mode flag.bunnei2017-12-301-1/+1
|
* thread: Main thread should be ready by default, all others dormant.bunnei2017-12-301-4/+3
|
* kernel: Various 64-bit fixes in memory/process/threadbunnei2017-12-291-5/+5
|
* hle: Use Switch formatted result codes.bunnei2017-11-011-3/+2
|
* hle: Fix QueryMemory response for MemoryInfo.bunnei2017-10-201-1/+1
|
* Merge remote-tracking branch 'upstream/master' into nxbunnei2017-10-101-23/+45
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # src/core/CMakeLists.txt # src/core/arm/dynarmic/arm_dynarmic.cpp # src/core/arm/dyncom/arm_dyncom.cpp # src/core/hle/kernel/process.cpp # src/core/hle/kernel/thread.cpp # src/core/hle/kernel/thread.h # src/core/hle/kernel/vm_manager.cpp # src/core/loader/3dsx.cpp # src/core/loader/elf.cpp # src/core/loader/ncch.cpp # src/core/memory.cpp # src/core/memory.h # src/core/memory_setup.h
| * Merge pull request #2971 from Subv/per_process_memopsSebastian Valle2017-10-011-0/+6
| |\ | | | | | | Memory: Add overloads for ReadBlock and WriteBlock that operate on a specific process.
| | * Kernel/Thread: Added a helper function to get a thread's command buffer VAddr.Subv2017-10-011-0/+6
| | |
| * | Merge pull request #2967 from Subv/thread_wakeup_callbacksSebastian Valle2017-09-301-3/+10
| |\ \ | | |/ | |/| Kernel/Threads: When putting a thread to wait, specify a function to execute when it is awoken
| | * Kernel/Threads: When putting a thread to wait, specify a function to execute when it is awoken.Subv2017-09-281-3/+10
| | | | | | | | | | | | | | | | | | This change makes for a clearer (less confusing) path of execution in the scheduler, now the code to execute when a thread awakes is closer to the code that puts the thread to sleep (WaitSynch1, WaitSynchN). It also allows us to implement the special wake up behavior of ReplyAndReceive without hacking up WaitObject::WakeupAllWaitingThreads. If savestates are desired in the future, we can change this implementation to one similar to the CoreTiming event system, where we first register the callback functions at startup and assign their identifiers to the Thread callback variable instead of directly assigning a lambda to the wake up callback variable.
| * | Fixed type conversion ambiguityHuw Pascoe2017-09-301-9/+9
| | |
| * | Kernel/Thread: Allow specifying which process a thread belongs to when creating it.Subv2017-09-271-8/+9
| |/ | | | | | | Don't automatically assume that Thread::Create will only be called when the parent process is currently scheduled. This assumption will be broken when applets or system modules are loaded.
| * memory: Add GetCurrentPageTable/SetCurrentPageTableMerryMage2017-09-241-7/+4
| | | | | | | | Don't expose Memory::current_page_table as a global.
| * Merge pull request #2842 from Subv/switchable_page_tableB3n302017-09-151-0/+12
| |\ | | | | | | Kernel/Memory: Give each process its own page table and allow switching the current page table upon reschedule
| | * Kernel/Threads: Don't clear the CPU instruction cache when performing a context switch from an idle thread into a thread in the same process.Subv2017-09-151-1/+3
| | | | | | | | | | | | We were unnecessarily clearing the cache when going from Process A -> Idle -> Process A, this caused extreme performance regressions.
| | * Kernel/Memory: Switch the current page table when a new process is scheduled.Subv2017-09-101-0/+10
| | |
| * | Kernel/Threads: Don't immediately switch to the new main thread when loading a new process.Subv2017-08-221-5/+1
| |/ | | | | | | | | This is necessary for loading multiple processes at the same time. The main thread will be automatically scheduled when necessary once the scheduler runs.
* | loader: Various improvements for NSO/NRO loaders.bunnei2017-10-101-1/+1
| |
* | kernel: Various threading fixes to support 64-bit addressing.bunnei2017-09-301-3/+3
|/
* ResultVal: Remove MoveFrom()Yuri Kunde Schlesner2017-06-191-2/+2
| | | | | Replace it with std::move(result_val).Unwrap(), or Foo().Unwrap() in case you already have an rvalue.
* Kernel: Move HandleTable to a separate fileYuri Kunde Schlesner2017-05-301-0/+1
|
* Kernel: Centralize error definitions in errors.hYuri Kunde Schlesner2017-05-251-8/+16
|
* Threads: Check the process' resource limit for the max allowed priority when creating a thread and remove the priority clamping code.Subv2017-01-111-8/+2
|
* Thread: Added priority range checking to svcSetThreadPriority and removed priority clamping code from Thread::SetPriority.Subv2017-01-111-18/+2
|
* Merge pull request #2410 from Subv/sleepthreadbunnei2017-01-071-0/+4
|\ | | | | Don't yield execution in SleepThread(0) if there are no available threads to run
| * Kernel: Don't attempt to yield execution in SleepThread(0) if there are no available threads to run.Subv2017-01-061-0/+4
| | | | | | | | With this we avoid an useless temporary deschedule of the current thread.
* | Merge pull request #2408 from Subv/priority_boostingbunnei2017-01-061-27/+0
|\ \ | | | | | | Kernel: Removed the priority boost code for starved threads.
| * | Kernel: Removed the priority boost code for starved threads.Subv2017-01-051-27/+0
| |/ | | | | | | | | | | After hwtesting and reverse engineering the kernel, it was found that the CTROS scheduler performs no priority boosting for threads like this, although some other forms of scheduling priority-starved threads might take place. For example, it was found that hardware interrupts might cause low-priority threads to run if the CPU is preempted in the middle of an SVC handler that deschedules the current (high priority) thread before scheduling it again.
* / Kernel: Remove some unused functions.Subv2017-01-051-23/+0
|/
* Kernel: Add some asserts to enforce the invariants in the scheduler.Subv2017-01-051-2/+5
|
* Kernel: Remove Thread::wait_objects_index and use wait_objects to hold all the objects that a thread is waiting on.Subv2017-01-051-0/+5
|
* Kernel: Use different thread statuses when a thread calls WaitSynchronization1 and WaitSynchronizationN with wait_all = true.Subv2017-01-041-4/+7
| | | | | | | | This commit removes the overly general THREADSTATUS_WAIT_SYNCH and replaces it with two more granular statuses: THREADSTATUS_WAIT_SYNCH_ANY when a thread waits on objects via WaitSynchronization1 or WaitSynchronizationN with wait_all = false. THREADSTATUS_WAIT_SYNCH_ALL when a thread waits on objects via WaitSynchronizationN with wait_all = true.
* Kernel/Mutex: Propagate thread priority changes to other threads inheriting the priority via mutexesSubv2017-01-041-4/+17
|
* Kernel/Mutex: Implemented priority inheritance.Subv2017-01-041-3/+3
| | | | | | | The implementation is based on reverse engineering of the 3DS's kernel. A mutex holder's priority will be temporarily boosted to the best priority among any threads that want to acquire any of its held mutexes. When the holder releases the mutex, it's priority will be boosted to the best priority among the threads that want to acquire any of its remaining held mutexes.
* Kernel: Object ShouldWait and Acquire calls now take a thread as a parameter.Subv2017-01-041-3/+3
| | | | This will be useful when implementing mutex priority inheritance.
* ThreadContext: Move from "core" to "arm_interface".bunnei2016-12-221-3/+3
|
* core: Replace "AppCore" nomenclature with just "CPU".bunnei2016-12-221-3/+3
|
* core: Remove HLE module, consolidate code & various cleanups.bunnei2016-12-221-4/+1
|
* core: Consolidate core and system state, remove system module & cleanups.bunnei2016-12-221-3/+3
|
* Thread: remove the thread from the thread list when exitingwwylele2016-12-171-2/+9
|
* Properly remove a thread from its wait_objects' waitlist when it is awoken by a timeout.Subv2016-12-101-0/+4
|
* Threading: Reworked the way our scheduler works.Subv2016-12-041-94/+3
| | | | | | | | | | Threads will now be awakened when the objects they're waiting on are signaled, instead of repeating the WaitSynchronization call every now and then. The scheduler is now called once after every SVC call, and once after a thread is awakened from sleep by its timeout callback. This new implementation is based off reverse-engineering of the real kernel. See https://gist.github.com/Subv/02f29bd9f1e5deb7aceea1e8f019c8f4 for a more detailed description of how the real kernel handles rescheduling.
* Fix typosRicardo de Almeida Gonzaga2016-10-201-1/+1
|
* implement wait tree widgetwwylele2016-09-221-0/+4
|
* Use negative priorities to avoid special-casing the self-includeYuri Kunde Schlesner2016-09-211-1/+1
|
* Remove empty newlines in #include blocks.Emmanuel Gil Peyrot2016-09-211-3/+1
| | | | | | | This makes clang-format useful on those. Also add a bunch of forgotten transitive includes, which otherwise prevented compilation.
* Manually tweak source formatting and then re-run clang-formatYuri Kunde Schlesner2016-09-191-4/+2
|
* Sources: Run clang-format on everything.Emmanuel Gil Peyrot2016-09-181-49/+65
|
* arm: ResetContext shouldn't be part of ARM_Interface.bunnei2016-09-151-1/+17
|
* Merge pull request #1869 from wwylele/dont-be-lazyYuri Kunde Schlesner2016-06-291-2/+6
|\ | | | | Switch context to the same thread if necessary
| * Switch context on the same thread if necessarywwylele2016-05-301-2/+6
| |
* | Thread: update timeout when rerunning WaitSynchwwylele2016-06-041-0/+49
|/
* Kernel/Thread: Remove use of Memory::GetPointerMerryMage2016-05-211-1/+1
|
* Set fpscr for new threadsJannik Vogel2016-05-171-0/+2
|
* Merge pull request #1695 from Subv/tls_allocbunnei2016-05-131-17/+67
|\ | | | | Kernel/Threads: Dynamically allocate the TLS region for threads.
| * Kernel/Threads: Dynamically allocate the TLS region for threads in the BASE region of the linear heap.Subv2016-05-071-17/+67
| | | | | | | | | | | | Each thread gets a 0x200-byte area from the 0x1000-sized page, when all 8 thread slots in a single page are used up, the kernel allocates a new page to hold another 8 entries. This is consistent with what the real kernel does.
* | hle: Get rid of global access to g_rescheduleLioncash2016-03-211-1/+2
|/ | | | | This shouldn't be directly exposed if there's already a partial API that operates on it. We can just provide the rest of that API.
* SVC: Fixed ArbitrateAddress to behave as it does on hardware.Subv2015-12-281-1/+1
| | | | This was verified with hwtests that i plan to upload later on.
* Kernel: Implement svcGetSystemInfoYuri Kunde Schlesner2015-12-011-0/+3
| | | | | This makes smealum/ctrulib@b96dd51d3349961189d4ab1bc2a5c45deff21c09 work with Citra.
* Silence -Wsign-compare warnings.Rohit Nirmal2015-10-071-1/+1
|
* Kernel: Implement svcGetProcessInfo in a basic wayYuri Kunde Schlesner2015-08-161-1/+3
| | | | | This also adds some basic memory usage accounting. These two types are used by Super Smash Bros. during startup.
* dyncom: Rename armdefs.h to armstate.hLioncash2015-07-261-1/+1
|
* Kernel/Scheduling: Clean up a thread's wait_objects when its scheduled.Subv2015-07-211-0/+8
| | | | They'll be reset if needed during the next svcWaitSynchronization call (if there's any pending)
* Ensure all kernel objects are released during shutdownYuri Kunde Schlesner2015-07-171-7/+14
| | | | | | | | This commit fixes several kernel object leaks. The most severe of them was threads not being removed from the private handle table used for CoreTiming events. This resulted in Threads never being released, which in turn held references to Process, causing CodeSets to never be freed when loading other applications.
* kernel: Fix svcWaitSynch to always acquire requested wait objects.bunnei2015-06-171-50/+26
|
* Remove every trailing whitespace from the project (but externals).Emmanuel Gil Peyrot2015-05-291-4/+4
|
* Kernel: Move reschedules from SVCs to actual mechanisms that reschedule.bunnei2015-05-211-0/+6
|
* Memmap: Re-organize memory function in two filesYuri Kunde Schlesner2015-05-151-1/+1
| | | | | | | memory.cpp/h contains definitions related to acessing memory and configuring the address space mem_map.cpp/h contains higher-level definitions related to configuring the address space accoording to the kernel and allocating memory.
* thread: Fix a conditional check in RescheduleLioncash2015-05-141-1/+1
|
* Merge pull request #748 from Subv/tls_maxbunnei2015-05-121-6/+15
|\ | | | | Core/Memory: Add TLS support for creating up to 300 threads
| * Core/Memory: Add TLS support for creating up to 300 threadsSubv2015-05-121-6/+15
| |
* | Merge pull request #751 from yuriks/idle-threadbunnei2015-05-121-27/+19
|\ \ | | | | | | Thread: Remove the idle thread
| * | Thread: Remove the idle threadYuri Kunde Schlesner2015-05-121-27/+19
| | | | | | | | | | | | Instead just use nullptr to represent no thread is active.
* | | Merge pull request #757 from Subv/schedulingbunnei2015-05-121-0/+2
|\ \ \ | |_|/ |/| | Core/Scheduling: Prepare the new priority in the thread queue when svcSetPriority is called
| * | Core/Scheduling: Prepare the new priority in the thread queue when svcSetPriority is calledSubv2015-05-121-0/+2
| |/
* | Merge pull request #750 from Subv/process_svcYuri Kunde Schlesner2015-05-121-0/+2
|\ \ | |/ |/| Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThread
| * Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThreadSubv2015-05-111-0/+2
| |
* | Thread: Correctly set main thread initial stack positionYuri Kunde Schlesner2015-05-111-2/+2
|/
* fixup! Set the TLS address in the schedulerSubv2015-05-111-2/+5
|
* Core/Memory: Give every emulated thread it's own TLS area.Subv2015-05-111-1/+9
| | | | | The TLS area for thread T with id Ti is located at TLS_AREA_VADDR + (Ti - 1) * 0x200. This allows some games like Mario Kart 7 to continue further.
* Memory: Re-organize and rename memory area address constantsYuri Kunde Schlesner2015-05-091-2/+3
|
* Common: Remove common.hYuri Kunde Schlesner2015-05-071-1/+3
|
* Kernel: Properly initialize and shutdown all modules.bunnei2015-05-021-2/+8
|
* Kernel: Implemented priority inheritance for mutexes.bunnei2015-04-101-3/+7
|
* Thread: Implement priority boost for starved threads.bunnei2015-04-101-12/+36
| | | | | | SVC: Return correct error code on invalid CreateThread processor ID. SVC: Assert when creating a thread with an invalid userland priority.
* Misc cleanup of common and related functionsarchshift2015-02-201-2/+3
|
* Asserts: break/crash program, fit to style guide; log.h->assert.harchshift2015-02-111-8/+6
| | | | | | | Involves making asserts use printf instead of the log functions (log functions are asynchronous and, as such, the log won't be printed in time) As such, the log type argument was removed (printf obviously can't use it, and it's made obsolete by the file and line printing) Also removed some GEKKO cruft.
* Scheduler refactor Pt. 1Kevin Hartman2015-02-101-185/+175
| | | | | | | | | | | | | * Simplifies scheduling logic, specifically regarding thread status. It should be much clearer which statuses are valid for a thread at any given point in the system. * Removes dead code from thread.cpp. * Moves the implementation of resetting a ThreadContext to the corresponding core's implementation. Other changes: * Fixed comments in arm interfaces. * Updated comments in thread.cpp * Removed confusing, useless, functions like MakeReady() and ChangeStatus() from thread.cpp. * Removed stack_size from Thread. In the CTR kernel, the thread's stack would be allocated before thread creation.
* Kernel: Stop creating useless Handles during object creationYuri Kunde Schlesner2015-02-021-8/+0
| | | | | They're finally unnecessary, and will stop cluttering the application's handle table.
* Kernel: Make WaitObjects share ownership of Threads waiting on themYuri Kunde Schlesner2015-02-021-0/+3
| | | | | | | | | | | | | | | | During normal operation, a thread waiting on an WaitObject and the object hold mutual references to each other for the duration of the wait. If a process is forcefully terminated (The CTR kernel has a SVC to do this, TerminateProcess, though no equivalent exists for threads.) its threads would also be stopped and destroyed, leaving dangling pointers in the WaitObjects. The solution is to simply have the Thread remove itself from WaitObjects when it is stopped. The vector of Threads in WaitObject has also been changed to hold SharedPtrs, just in case. (Better to have a reference cycle than a crash.)
* Explicitly instantiate constructors/destructors for Kernel objectsYuri Kunde Schlesner2015-02-021-2/+2
| | | | | | This should speed up compile times a bit, as well as enable more liberal use of forward declarations. (Due to SharedPtr not trying to emit the destructor anymore.)
* Mutex: Replace g_mutex_held_locks with a set inside ThreadYuri Kunde Schlesner2015-02-021-0/+3
|
* Kernel: Introduce unique Object ids for debuggingYuri Kunde Schlesner2015-02-021-5/+5
|
* Kernel: Use separate Handle tables for CoreTiming userdataYuri Kunde Schlesner2015-02-021-11/+11
| | | | This is to support the removal of GetHandle soon
* Thread: Modernize two functions that slipped through previous rebasesYuri Kunde Schlesner2015-02-021-5/+4
|
* arm: Clean up ARMul_StateLioncash2015-02-011-1/+1
| | | | Remove unnecessary/unused struct variables.
* Thread: Fix WaitSynchronization1 to not set register 1 on thread wakeup.bunnei2015-01-221-15/+28
|
* Thread: Use std::find in CheckWait_WaitObject.bunnei2015-01-221-4/+5
|
* Mutex: Cleanup and remove redundant code.bunnei2015-01-221-1/+1
|
* Kernel: Renamed some functions for clarity.bunnei2015-01-221-1/+1
| | | | | - ReleaseNextThread->WakeupNextThread - ReleaseAllWaitingThreads->WakeupAllWaitingThreads.
* Kernel: Changed "ShouldWait" to return bool and "Acquire" to return void.bunnei2015-01-221-7/+5
|
* WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual.bunnei2015-01-221-2/+2
|
* Kernel: Moved Wait and Acquire to WaitObject, added way to retrieve a WaitObject safely.bunnei2015-01-221-1/+1
|
* AddressArbiter: Changed to Kernel::Object, big cleanup, removed code that made no sense.bunnei2015-01-221-17/+25
|
* Kernel: Get rid of WaitTypes and simplify lots of code, removing hacks.bunnei2015-01-221-46/+19
|
* WaitSynchronizationN: Refactor to fix several bugsbunnei2015-01-221-33/+28
| | | | | | - Separate wait checking from waiting the current thread - Resume thread when wait_all=true only if all objects are available at once - Set output to correct wait object index when there are duplicate handles
* Kernel: Separate WaitSynchronization into Wait and Acquire methods.bunnei2015-01-221-1/+5
|
* WaitSynchronizationN: Implement return valuesbunnei2015-01-221-19/+75
|
* Thread: Keep track of multiple wait objects.bunnei2015-01-221-11/+24
|
* Kernel: Added WaitObject and changed "waitable" objects inherit from it.bunnei2015-01-221-9/+2
|
* Merge pull request #466 from Subv/wakebunnei2015-01-111-0/+3
|\ | | | | Thread: Prevent waking a thread multiple times.
| * Thread: Prevent waking a thread multiple times.Subv2015-01-111-0/+3
| | | | | | | | If a thread was woken up by something, cancel the wakeup timeout.
* | Kernel: Start using boost::intrusive_ptr for lifetime managementYuri Kunde Schlesner2015-01-091-33/+30
|/
* Thread: Fix nullptr access in a logging functionYuri Kunde Schlesner2015-01-091-1/+2
|
* Thread: Rename thread_queue => thread_listYuri Kunde Schlesner2015-01-091-6/+6
|
* Thread: Reduce use of Handles and move some funcs to inside the class.Yuri Kunde Schlesner2015-01-091-213/+127
|
* Kernel: Move Thread's definition to the header fileYuri Kunde Schlesner2015-01-091-51/+9
|
* Move ThreadContext to core/core.h and deal with the falloutYuri Kunde Schlesner2015-01-091-4/+5
|
* SVC: Fixed SleepThread.Subv2015-01-091-8/+32
| | | | It will now properly wait the specified number of nanoseconds and then wake up the thread.
* Threads: Use a dummy idle thread when no other are ready.Subv2015-01-081-1/+22
| | | | This thread will not actually execute instructions, it will only advance the timing/events and try to yield immediately to the next ready thread, if there aren't any ready threads then it will be rescheduled and start its job again.
* Common: Clean up ThreadQueueListYuri Kunde Schlesner2015-01-071-1/+1
| | | | | | | | Replace all the C-style complicated buffer management with a std::deque. In addition to making the code easier to understand it also adds support for non-POD IdTypes. Also clean the rest of the code to follow our code style.
* Kernel: New handle managerYuri Kunde Schlesner2014-12-281-1/+2
| | | | | | | | | | | This handle manager more closely mirrors the behaviour of the CTR-OS one. In addition object ref-counts and support for DuplicateHandle have been added. Note that support for DuplicateHandle is still experimental, since parts of the kernel still use Handles internally, which will likely cause troubles if two different handles to the same object are used to e.g. wait on a synchronization primitive.
* Kernel: Replace GetStaticHandleType by HANDLE_TYPE constantsYuri Kunde Schlesner2014-12-281-2/+2
|
* Rename ObjectPool to HandleTableYuri Kunde Schlesner2014-12-281-11/+11
|
* Merge pull request #291 from purpasmart96/licensebunnei2014-12-211-1/+1
|\ | | | | License change
| * License changepurpasmart962014-12-211-1/+1
| |
* | Thread: Wait current thread on svc_SleepThreadbunnei2014-12-211-20/+33
| | | | | | | | | | | | - Removed unused VBLANK sleep mode - Added error log for bad context switch - Renamed VerifyWait to CheckWaitType to be more clear
* | Kernel: Implement support for current thread pseudo-handleYuri Kunde Schlesner2014-12-201-2/+1
|/ | | | This boots a few (mostly Nintendo 1st party) games further.
* Convert old logging calls to new logging macrosYuri Kunde Schlesner2014-12-131-12/+12
|
* Merge pull request #256 from Subv/mutexbunnei2014-12-111-0/+4
|\ | | | | Kernel/Mutex: Properly lock the mutex when a thread enters it
| * Mutex: Release all held mutexes when a thread exits.Subv2014-12-071-0/+4
| |
* | Thread: Fixed to wait on address when in arbitration.bunnei2014-12-091-10/+19
|/
* Threads: Remove a redundant function.Subv2014-12-041-9/+1
| | | | Use the next_thread_id variable directly.
* Threads: Implemented a sequential thread idSubv2014-12-041-3/+13
|
* SVC: Implemented GetThreadId.Subv2014-12-041-0/+16
| | | | For now threads are using their Handle value as their Id, it should not really cause any problems because Handle values are unique in Citra, but it should be changed. I left a ToDo there because this is not correct behavior as per hardware.
* Thread: Check that thread is actually in "wait state" when verifying wait.bunnei2014-11-261-1/+1
|
* Use pointers instead of passing handles around in some functions.Yuri Kunde Schlesner2014-11-241-19/+15
|
* Remove duplicated docs/update them for changed parameters.Yuri Kunde Schlesner2014-11-241-5/+0
|
* HLE: Revamp error handling throrough the HLE codeYuri Kunde Schlesner2014-11-241-21/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | All service calls in the CTR OS return result codes indicating the success or failure of the call. Previous to this commit, Citra's HLE emulation of services and the kernel universally either ignored errors or returned dummy -1 error codes. This commit makes an initial effort to provide an infrastructure for error reporting and propagation which can be use going forward to make HLE calls accurately return errors as the original system. A few parts of the code have been updated to use the new system where applicable. One part of this effort is the definition of the `ResultCode` type, which provides facilities for constructing and parsing error codes in the structured format used by the CTR. The `ResultVal` type builds on `ResultCode` by providing a container for values returned by function that can report errors. It enforces that correct error checking will be done on function returns by preventing the use of the return value if the function returned an error code. Currently this change is mostly internal since errors are still suppressed on the ARM<->HLE border, as a temporary compatibility hack. As functionality is implemented and tested this hack can be eventually removed.
* Merge pull request #211 from linkmauve/masterbunnei2014-11-191-19/+19
|\ | | | | Remove trailing spaces from the entire project
| * Remove trailing spaces in every file but the ones imported from SkyEye, AOSP or generatedEmmanuel Gil Peyrot2014-11-191-19/+19
| |
* | Add static to some variablesLioncash2014-11-191-22/+22
|/
* Add `override` keyword through the code.Yuri Kunde Schlesner2014-10-261-4/+4
| | | | This was automated using `clang-modernize`.
* core: Prune redundant includesarchshift2014-09-091-3/+0
|
* Threading: Fix thread starting to execute first instruction correctly.bunnei2014-08-281-0/+5
|
* Core: Alter the kernel string functions to use std::string instead of const char*.Lioncash2014-08-181-10/+7
| | | | Most functions already operate on std::strings. This also removes the need to manually null terminate thread names.
* Thread: Added more descriptive comment to WaitCurrentThread.bunnei2014-08-071-1/+5
|
* Thread: Added functions to resume threads from address arbitration.bunnei2014-07-091-0/+37
| | | | | | Thread: Cleaned up arbitrate address functions. Thread: Cleaned up ArbitrateAllThreads function.
* Thread: Renamed occurrences of "t" to "thread" to improve readability.bunnei2014-06-131-48/+45
|
* Thread: Cleaned up VerifyWait, fixed issue where nullptr msg could unnecessarily be logged.bunnei2014-06-131-9/+7
|
* HLE: Removed usnused EatCycles function.bunnei2014-06-131-9/+0
|
* Thread: Moved position of * in arguments.bunnei2014-06-131-2/+2
|
* Thread: Updated VerifyWait to be more readable (but functionally the same).bunnei2014-06-131-4/+3
|
* HLE: Updated all uses of NULL to nullptr (to be C++11 compliant)bunnei2014-06-131-7/+7
|
* HLE: Updated various handle debug assertions to be more clear.bunnei2014-06-131-2/+2
|
* Kernel: Updated several member functions to be constbunnei2014-06-131-3/+3
|
* Thread: Fixed bug with ResetThread where cpu_registers[15] was being incorrectly setbunnei2014-06-131-1/+1
|
* Kernel: Made SyncRequest not pure virtual, with a default implementation of error (as this is not required for all kernel objects)bunnei2014-06-131-10/+0
|
* Kernel: Added real support for thread and event blockingbunnei2014-06-131-33/+88
| | | | | | | | | | | | | - SVC: Added ExitThread support - SVC: Added SignalEvent support - Thread: Added WAITTYPE_EVENT for waiting threads for event signals - Thread: Added support for blocking on other threads to finish (e.g. Thread::Join) - Thread: Added debug function for printing current threads ready for execution - Thread: Removed hack/broken thread ready state code from Kernel::Reschedule - Mutex: Moved WaitCurrentThread from SVC to Mutex::WaitSynchronization - Event: Added support for blocking threads on event signalling Kernel: Added missing algorithm #include for use of std::find on non-Windows platforms.
* svc: added GetThreadPriority and SetThreadPriority, added (incomplete) DuplicateHandle supportbunnei2014-06-021-0/+45
|
* kernel: changed main thread priority to default, updated Kernel::Reschedule to use PrepareReschedulebunnei2014-06-021-3/+3
|
* thread: updated Reschedule to sit at a synchronization barrier when no other threads are ready for executionbunnei2014-06-011-0/+18
|
* kernel: added WaitSynchronization method to Kernel::Objectbunnei2014-05-271-0/+11
|
* kernel: updated SyncRequest to take boolean thread wait result as a parameterbunnei2014-05-271-2/+6
|
* kernel: add a SyncRequest method to KernelObject for use with svcSendSyncRequestbunnei2014-05-271-0/+5
|
* thread: renamed "WaitCurThread" to "WaitCurrentThread", removed unused "reason" argumentbunnei2014-05-231-2/+2
|
* thread: removed unused SwitchContext/Reschedule reason field, added missing arg parameter to SVC CreateThreadbunnei2014-05-231-3/+3
|
* kernel: refactored function naming to remove "__" prefixbunnei2014-05-231-39/+39
|
* thread: moved ThreadStatus/WaitType to header, added support for arg on CreateThread, added correct CPSR resetbunnei2014-05-231-34/+15
|
* thread: fixed bug where result of __NextThread was not being properly checked when NULLbunnei2014-05-221-1/+1
|
* thread: added correct lowest thread priority, added a thread priority check, and added some commentsbunnei2014-05-211-0/+3
|
* thread: exposed ResumeThreadFromWait function for use in other kernel modulesbunnei2014-05-211-8/+8
|
* thread: moved threading calls to the Kernel namespacebunnei2014-05-211-89/+95
|
* ARM_Interface: added SaveContext and LoadContext functions for HLE thread switchingbunnei2014-05-211-36/+2
|
* renamed "syscall" module to "svc" (more accurate naming)bunnei2014-05-211-1/+1
|
* thread: whitespace change - fixed * and & placementbunnei2014-05-211-25/+25
|
* - created a Kernel namespacebunnei2014-05-211-9/+9
| | | | | - cleaned up Kernel code a bit (moved stuff into namespace, fixed whitespace issues) - added handle types for all different CTROS handles
* - moved Handle/Result definitions to kernel.hbunnei2014-05-191-2/+0
| | | | - added ResetType enum
* changed a commentbunnei2014-05-171-1/+1
|
* - added enum ThreadProcessorIdbunnei2014-05-171-51/+90
| | | | | - reorganized some kernel thread functions - added placeholder __KernelWaitThread_Synchronization function
* - replaced KERNELOBJECT_MAX_NAME_LENGTH with KERNEL_MAX_NAME_LENGTHbunnei2014-05-171-4/+5
| | | | - added KERNEL_DEFAULT_STACK_SIZE definition (0x4000)
* completely gutted/refactored threading code to be simplerbunnei2014-05-161-616/+228
|
* - added helper function for __KernelCreateThreadbunnei2014-05-151-4/+70
| | | | | - added __KernelSwitchToThread for enabling a thread - added __KernelRotateThreadReadyQueue
* fixed thread reset to not set stack addressbunnei2014-05-141-1/+1
|
* various cleanups / remove unused codebunnei2014-05-141-65/+28
|
* added a bunch of threading code, recycled from PPSSPP, with lots of hacks in for 3DS... doesn't really do much yet. Just a jumping off pointbunnei2014-05-141-64/+524
|
* added initial kernel/thread modulesbunnei2014-05-101-0/+228