summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/thread.cpp (unfollow)
Commit message (Collapse)AuthorFilesLines
2018-09-18arm_interface: Remove ARM11-isms from the CPU interfaceLioncash1-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.
2018-09-15Port #4182 from Citra: "Prefix all size_t with std::"fearlessTobi1-1/+1
2018-09-12kernel/errors: Correct error codes for invalid thread priority and invalid processor IDLioncash1-2/+2
2018-08-31core/core: Replace includes with forward declarations where applicableLioncash1-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.
2018-08-29kernel: Eliminate kernel global stateLioncash1-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.
2018-08-25core: Namespace all code in the arm subdirectory under the Core namespaceLioncash1-2/+2
Gets all of these types and interfaces out of the global namespace.
2018-08-13Core::CoreTiming: add UnscheduleEventThreadsafeB3n301-1/+1
2018-08-13Kernel/Threads: Lock the HLE mutex when executing the wakeup callback.Subv1-0/+5
Another thread might be in the middle of a reschedule, thus altering the state of the schedulers.
2018-08-13Kernel/Thread: Always use the threadsafe option when scheduling wakeups.Subv1-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.
2018-08-12Kernel/Mutex: Don't duplicate threads in the mutex waiter list.Subv1-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.
2018-08-04kernel/thread: Fix potential crashes introduced in 26de4bb521b1ace7af76eff4f6956cb23ac0d58cLioncash1-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).
2018-08-03core/memory: Get rid of 3DS leftoversLioncash1-31/+2
Removes leftover code from citra that isn't needed.
2018-08-02kernel/thread: Make GetFreeThreadLocalSlot()'s loop indices size_tLioncash1-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.
2018-08-02kernel/thread: Make GetFreeThreadLocalSlot() reference parameter a const referenceLioncash1-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.
2018-08-02kernel/thread: Make GetFreeThreadLocalSlot() internally linkedLioncash1-1/+1
This function isn't used outside of this translation unit, so we can make it internally linked.
2018-08-02kernel: Move object class to its own source filesLioncash1-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.
2018-07-31kernel: Remove unnecessary includesLioncash1-2/+4
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_utilMerryMage1-0/+1
2018-07-21CPU: Save and restore the TPIDR_EL0 system register on every context switch.Subv1-0/+1
Note that there's currently a dynarmic bug preventing this register from being written.
2018-07-20thread: Convert ThreadStatus into an enum classLioncash1-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.
2018-07-19core/memory, core/hle/kernel: Use std::move where applicableLioncash1-1/+1
Avoids pointless copies
2018-07-19core: Don't construct instance of Core::System, just to access its live instanceLioncash1-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.
2018-07-03Update clang formatJames Rowe1-1/+1
2018-07-03Rename logging macro back to LOG_*James Rowe1-5/+5
2018-06-21Kernel/Arbiters: Implement WaitForAddressMichael Scire1-0/+6
2018-06-02Kernel/Threads: A thread waking up by timeout from a WaitProcessWideKey may already have an assigned lock owner.Subv1-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.
2018-05-31Kernel/Thread: Corrected a typo that caused the affinity mask to never be changed.Subv1-2/+2
2018-05-30Kernel/Thread: Corrected a typo in an assert about the processor id.Subv1-1/+1
2018-05-11thread: Rename mask to affinity_masks.bunnei1-2/+2
2018-05-11thread: Support core change on ResumeFromWait and improve ChangeCore.bunnei1-37/+68
2018-05-11thread: Initialize ideal_core and mask members.bunnei1-0/+2
2018-05-11threading: Reschedule only on cores that are necessary.bunnei1-1/+1
2018-05-11thread: Implement ChangeCore function.bunnei1-1/+52
2018-05-11core: Implement multicore support.bunnei1-8/+8
2018-04-30core_timing: Namespace all functions and constants in core_timing's headerLioncash1-1/+2
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-compatibleLioncash1-2/+2
2018-04-26kernel: Migrate logging macros to fmt-compatible onesLioncash1-7/+8
2018-04-23Kernel: Implemented mutex priority inheritance.Subv1-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.
2018-04-21Kernel: Remove unused ConditionVariable class.Subv1-9/+0
2018-04-21Kernel: Remove old and unused Mutex code.Subv1-3/+0
2018-04-21Kernel: Corrected the implementation of svcArbitrateLock and svcArbitrateUnlock.Subv1-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.
2018-03-31memory: Fix stack region.bunnei1-1/+1
2018-03-19thread: Add THREADSTATUS_WAIT_HLE_EVENT, remove THREADSTATUS_WAIT_ARB.bunnei1-18/+3
2018-03-16kernel: Move stack region outside of application heap.bunnei1-1/+1
2018-03-16MemoryState: Add additional memory states and improve naming.bunnei1-1/+1
2018-03-14core: Move process creation out of global state.bunnei1-2/+2
2018-02-27thread: Clear the process list on shutdown.Jules Blok1-1/+3
2018-02-18kernel: Use Scheduler class for threading.bunnei1-155/+14
2018-02-18kernel: Remove unused address_arbiter code.bunnei1-34/+0
2018-02-18 Kernel/IPC: Add a small delay after each SyncRequest to prevent thread starvation.Subv1-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.
2018-02-14thread: Silence formatting specifier warningsLioncash1-2/+3
2018-01-09Kernel: Allow chaining WaitSynchronization calls inside a wakeup callback.Subv1-8/+17
2018-01-09CoreTiming: Reworked CoreTiming (cherry-picked from Citra #3119)B3n301-3/+2
* CoreTiming: New CoreTiming; Add Test for CoreTiming
2018-01-03arm: Remove SkyEye/Dyncom code that is ARMv6-only.bunnei1-4/+2
2017-12-31thread: Keep track of the initially created handle.bunnei1-1/+2
This is kinda crufty, but we need it for now to update guest state variables.
2017-12-30thread: Main thread should set thread handle to reg 1.bunnei1-1/+4
2017-12-30thread: Remove THUMB mode flag.bunnei1-1/+1
2017-12-30thread: Main thread should be ready by default, all others dormant.bunnei1-4/+3
2017-12-29kernel: Various 64-bit fixes in memory/process/threadbunnei1-5/+5
2017-11-01hle: Use Switch formatted result codes.bunnei1-3/+2
2017-10-20hle: Fix QueryMemory response for MemoryInfo.bunnei1-1/+1
2017-10-10loader: Various improvements for NSO/NRO loaders.bunnei1-1/+1
2017-10-01Kernel/Thread: Added a helper function to get a thread's command buffer VAddr.Subv1-0/+6
2017-09-30kernel: Various threading fixes to support 64-bit addressing.bunnei1-3/+3
2017-09-30Fixed type conversion ambiguityHuw Pascoe1-9/+9
2017-09-28Kernel/Threads: When putting a thread to wait, specify a function to execute when it is awoken.Subv1-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.
2017-09-27Kernel/Thread: Allow specifying which process a thread belongs to when creating it.Subv1-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.
2017-09-24memory: Add GetCurrentPageTable/SetCurrentPageTableMerryMage1-7/+4
Don't expose Memory::current_page_table as a global.
2017-09-15Kernel/Threads: Don't clear the CPU instruction cache when performing a context switch from an idle thread into a thread in the same process.Subv1-1/+3
We were unnecessarily clearing the cache when going from Process A -> Idle -> Process A, this caused extreme performance regressions.
2017-09-10Kernel/Memory: Switch the current page table when a new process is scheduled.Subv1-0/+10
2017-08-22Kernel/Threads: Don't immediately switch to the new main thread when loading a new process.Subv1-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.
2017-06-19ResultVal: Remove MoveFrom()Yuri Kunde Schlesner1-2/+2
Replace it with std::move(result_val).Unwrap(), or Foo().Unwrap() in case you already have an rvalue.
2017-05-30Kernel: Move HandleTable to a separate fileYuri Kunde Schlesner1-0/+1
2017-05-25Kernel: Centralize error definitions in errors.hYuri Kunde Schlesner1-8/+16
2017-01-11Threads: Check the process' resource limit for the max allowed priority when creating a thread and remove the priority clamping code.Subv1-8/+2
2017-01-11Thread: Added priority range checking to svcSetThreadPriority and removed priority clamping code from Thread::SetPriority.Subv1-18/+2
2017-01-06Kernel: Don't attempt to yield execution in SleepThread(0) if there are no available threads to run.Subv1-0/+4
With this we avoid an useless temporary deschedule of the current thread.
2017-01-05Kernel: Remove some unused functions.Subv1-23/+0
2017-01-05Kernel: Removed the priority boost code for starved threads.Subv1-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.
2017-01-05Kernel: Add some asserts to enforce the invariants in the scheduler.Subv1-2/+5
2017-01-05Kernel: Remove Thread::wait_objects_index and use wait_objects to hold all the objects that a thread is waiting on.Subv1-0/+5
2017-01-04Kernel: Use different thread statuses when a thread calls WaitSynchronization1 and WaitSynchronizationN with wait_all = true.Subv1-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.
2017-01-04Kernel/Mutex: Propagate thread priority changes to other threads inheriting the priority via mutexesSubv1-4/+17
2017-01-04Kernel/Mutex: Implemented priority inheritance.Subv1-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.
2017-01-04Kernel: Object ShouldWait and Acquire calls now take a thread as a parameter.Subv1-3/+3
This will be useful when implementing mutex priority inheritance.
2016-12-22ThreadContext: Move from "core" to "arm_interface".bunnei1-3/+3
2016-12-22core: Replace "AppCore" nomenclature with just "CPU".bunnei1-3/+3
2016-12-22core: Remove HLE module, consolidate code & various cleanups.bunnei1-4/+1
2016-12-22core: Consolidate core and system state, remove system module & cleanups.bunnei1-3/+3
2016-12-17Thread: remove the thread from the thread list when exitingwwylele1-2/+9
2016-12-10Properly remove a thread from its wait_objects' waitlist when it is awoken by a timeout.Subv1-0/+4
2016-12-04Threading: Reworked the way our scheduler works.Subv1-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.
2016-10-20Fix typosRicardo de Almeida Gonzaga1-1/+1
2016-09-22implement wait tree widgetwwylele1-0/+4
2016-09-21Use negative priorities to avoid special-casing the self-includeYuri Kunde Schlesner1-1/+1
2016-09-21Remove empty newlines in #include blocks.Emmanuel Gil Peyrot1-3/+1
This makes clang-format useful on those. Also add a bunch of forgotten transitive includes, which otherwise prevented compilation.
2016-09-19Manually tweak source formatting and then re-run clang-formatYuri Kunde Schlesner1-4/+2
2016-09-18Sources: Run clang-format on everything.Emmanuel Gil Peyrot1-49/+65
2016-09-15arm: ResetContext shouldn't be part of ARM_Interface.bunnei1-1/+17
2016-06-04Thread: update timeout when rerunning WaitSynchwwylele1-0/+49
2016-05-30Switch context on the same thread if necessarywwylele1-2/+6
2016-05-21Kernel/Thread: Remove use of Memory::GetPointerMerryMage1-1/+1
2016-05-17Set fpscr for new threadsJannik Vogel1-0/+2
2016-05-07Kernel/Threads: Dynamically allocate the TLS region for threads in the BASE region of the linear heap.Subv1-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.
2016-03-21hle: Get rid of global access to g_rescheduleLioncash1-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.
2015-12-28SVC: Fixed ArbitrateAddress to behave as it does on hardware.Subv1-1/+1
This was verified with hwtests that i plan to upload later on.
2015-12-01Kernel: Implement svcGetSystemInfoYuri Kunde Schlesner1-0/+3
This makes smealum/ctrulib@b96dd51d3349961189d4ab1bc2a5c45deff21c09 work with Citra.
2015-10-07Silence -Wsign-compare warnings.Rohit Nirmal1-1/+1
2015-08-16Kernel: Implement svcGetProcessInfo in a basic wayYuri Kunde Schlesner1-1/+3
This also adds some basic memory usage accounting. These two types are used by Super Smash Bros. during startup.
2015-07-26dyncom: Rename armdefs.h to armstate.hLioncash1-1/+1
2015-07-21Kernel/Scheduling: Clean up a thread's wait_objects when its scheduled.Subv1-0/+8
They'll be reset if needed during the next svcWaitSynchronization call (if there's any pending)
2015-07-17Ensure all kernel objects are released during shutdownYuri Kunde Schlesner1-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.
2015-06-17kernel: Fix svcWaitSynch to always acquire requested wait objects.bunnei1-50/+26
2015-05-29Remove every trailing whitespace from the project (but externals).Emmanuel Gil Peyrot1-4/+4
2015-05-21Kernel: Move reschedules from SVCs to actual mechanisms that reschedule.bunnei1-0/+6
2015-05-15Memmap: Re-organize memory function in two filesYuri Kunde Schlesner1-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.
2015-05-14thread: Fix a conditional check in RescheduleLioncash1-1/+1
2015-05-12Thread: Remove the idle threadYuri Kunde Schlesner1-27/+19
Instead just use nullptr to represent no thread is active.
2015-05-12Core/Memory: Add TLS support for creating up to 300 threadsSubv1-6/+15
2015-05-12Core/Scheduling: Prepare the new priority in the thread queue when svcSetPriority is calledSubv1-0/+2
2015-05-11Core/HLE: Implemented the SVCs GetProcessId and GetProcessIdOfThreadSubv1-0/+2
2015-05-11Thread: Correctly set main thread initial stack positionYuri Kunde Schlesner1-2/+2
2015-05-11fixup! Set the TLS address in the schedulerSubv1-2/+5
2015-05-11Core/Memory: Give every emulated thread it's own TLS area.Subv1-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.
2015-05-09Memory: Re-organize and rename memory area address constantsYuri Kunde Schlesner1-2/+3
2015-05-07Common: Remove common.hYuri Kunde Schlesner1-1/+3
2015-05-02Kernel: Properly initialize and shutdown all modules.bunnei1-2/+8
2015-04-10Kernel: Implemented priority inheritance for mutexes.bunnei1-3/+7
2015-04-10Thread: Implement priority boost for starved threads.bunnei1-12/+36
SVC: Return correct error code on invalid CreateThread processor ID. SVC: Assert when creating a thread with an invalid userland priority.
2015-02-20Misc cleanup of common and related functionsarchshift1-2/+3
2015-02-11Asserts: break/crash program, fit to style guide; log.h->assert.harchshift1-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.
2015-02-10Scheduler refactor Pt. 1Kevin Hartman1-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.
2015-02-02Kernel: Stop creating useless Handles during object creationYuri Kunde Schlesner1-8/+0
They're finally unnecessary, and will stop cluttering the application's handle table.
2015-02-02Kernel: Make WaitObjects share ownership of Threads waiting on themYuri Kunde Schlesner1-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.)
2015-02-02Explicitly instantiate constructors/destructors for Kernel objectsYuri Kunde Schlesner1-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.)
2015-02-02Mutex: Replace g_mutex_held_locks with a set inside ThreadYuri Kunde Schlesner1-0/+3
2015-02-02Kernel: Introduce unique Object ids for debuggingYuri Kunde Schlesner1-5/+5
2015-02-02Kernel: Use separate Handle tables for CoreTiming userdataYuri Kunde Schlesner1-11/+11
This is to support the removal of GetHandle soon
2015-02-02Thread: Modernize two functions that slipped through previous rebasesYuri Kunde Schlesner1-5/+4
2015-02-01arm: Clean up ARMul_StateLioncash1-1/+1
Remove unnecessary/unused struct variables.
2015-01-22Thread: Fix WaitSynchronization1 to not set register 1 on thread wakeup.bunnei1-15/+28
2015-01-22Thread: Use std::find in CheckWait_WaitObject.bunnei1-4/+5
2015-01-22Mutex: Cleanup and remove redundant code.bunnei1-1/+1
2015-01-22Kernel: Renamed some functions for clarity.bunnei1-1/+1
- ReleaseNextThread->WakeupNextThread - ReleaseAllWaitingThreads->WakeupAllWaitingThreads.
2015-01-22Kernel: Changed "ShouldWait" to return bool and "Acquire" to return void.bunnei1-7/+5
2015-01-22WaitObject: Renamed "Wait" to "ShouldWait", made "ShouldWait" and "Acquire" pure virtual.bunnei1-2/+2
2015-01-22Kernel: Moved Wait and Acquire to WaitObject, added way to retrieve a WaitObject safely.bunnei1-1/+1
2015-01-22AddressArbiter: Changed to Kernel::Object, big cleanup, removed code that made no sense.bunnei1-17/+25
2015-01-22Kernel: Get rid of WaitTypes and simplify lots of code, removing hacks.bunnei1-46/+19
2015-01-22WaitSynchronizationN: Refactor to fix several bugsbunnei1-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
2015-01-22Kernel: Separate WaitSynchronization into Wait and Acquire methods.bunnei1-1/+5
2015-01-22WaitSynchronizationN: Implement return valuesbunnei1-19/+75
2015-01-22Thread: Keep track of multiple wait objects.bunnei1-11/+24
2015-01-22Kernel: Added WaitObject and changed "waitable" objects inherit from it.bunnei1-9/+2
2015-01-11Thread: Prevent waking a thread multiple times.Subv1-0/+3
If a thread was woken up by something, cancel the wakeup timeout.
2015-01-09Kernel: Start using boost::intrusive_ptr for lifetime managementYuri Kunde Schlesner1-33/+30
2015-01-09Thread: Fix nullptr access in a logging functionYuri Kunde Schlesner1-1/+2
2015-01-09Thread: Rename thread_queue => thread_listYuri Kunde Schlesner1-6/+6
2015-01-09Thread: Reduce use of Handles and move some funcs to inside the class.Yuri Kunde Schlesner1-213/+127
2015-01-09Kernel: Move Thread's definition to the header fileYuri Kunde Schlesner1-51/+9
2015-01-09Move ThreadContext to core/core.h and deal with the falloutYuri Kunde Schlesner1-4/+5
2015-01-09SVC: Fixed SleepThread.Subv1-8/+32
It will now properly wait the specified number of nanoseconds and then wake up the thread.
2015-01-08Threads: Use a dummy idle thread when no other are ready.Subv1-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.
2015-01-07Common: Clean up ThreadQueueListYuri Kunde Schlesner1-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.
2014-12-28Kernel: New handle managerYuri Kunde Schlesner1-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.
2014-12-28Kernel: Replace GetStaticHandleType by HANDLE_TYPE constantsYuri Kunde Schlesner1-2/+2
2014-12-28Rename ObjectPool to HandleTableYuri Kunde Schlesner1-11/+11
2014-12-21License changepurpasmart961-1/+1
2014-12-21Thread: Wait current thread on svc_SleepThreadbunnei1-20/+33
- Removed unused VBLANK sleep mode - Added error log for bad context switch - Renamed VerifyWait to CheckWaitType to be more clear
2014-12-20Kernel: Implement support for current thread pseudo-handleYuri Kunde Schlesner1-2/+1
This boots a few (mostly Nintendo 1st party) games further.
2014-12-13Convert old logging calls to new logging macrosYuri Kunde Schlesner1-12/+12
2014-12-09Thread: Fixed to wait on address when in arbitration.bunnei1-10/+19
2014-12-07Mutex: Release all held mutexes when a thread exits.Subv1-0/+4
2014-12-04Threads: Remove a redundant function.Subv1-9/+1
Use the next_thread_id variable directly.
2014-12-04Threads: Implemented a sequential thread idSubv1-3/+13
2014-12-04SVC: Implemented GetThreadId.Subv1-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.
2014-11-26Thread: Check that thread is actually in "wait state" when verifying wait.bunnei1-1/+1
2014-11-24Use pointers instead of passing handles around in some functions.Yuri Kunde Schlesner1-19/+15
2014-11-24Remove duplicated docs/update them for changed parameters.Yuri Kunde Schlesner1-5/+0
2014-11-24HLE: Revamp error handling throrough the HLE codeYuri Kunde Schlesner1-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.
2014-11-19Remove trailing spaces in every file but the ones imported from SkyEye, AOSP or generatedEmmanuel Gil Peyrot1-19/+19
2014-11-19Add static to some variablesLioncash1-22/+22
2014-10-26Add `override` keyword through the code.Yuri Kunde Schlesner1-4/+4
This was automated using `clang-modernize`.
2014-09-09core: Prune redundant includesarchshift1-3/+0
2014-08-31Threading: Fix thread starting to execute first instruction correctly.bunnei1-0/+5
2014-08-28Threading: Fix thread starting to execute first instruction correctly.bunnei1-0/+5
2014-08-18Core: Alter the kernel string functions to use std::string instead of const char*.Lioncash1-10/+7
Most functions already operate on std::strings. This also removes the need to manually null terminate thread names.
2014-08-07Thread: Added more descriptive comment to WaitCurrentThread.bunnei1-1/+5
2014-07-09Thread: Added functions to resume threads from address arbitration.bunnei1-0/+37
Thread: Cleaned up arbitrate address functions. Thread: Cleaned up ArbitrateAllThreads function.
2014-06-13Thread: Renamed occurrences of "t" to "thread" to improve readability.bunnei1-48/+45
2014-06-13Thread: Cleaned up VerifyWait, fixed issue where nullptr msg could unnecessarily be logged.bunnei1-9/+7
2014-06-13HLE: Removed usnused EatCycles function.bunnei1-9/+0
2014-06-13Thread: Moved position of * in arguments.bunnei1-2/+2
2014-06-13Thread: Updated VerifyWait to be more readable (but functionally the same).bunnei1-4/+3
2014-06-13HLE: Updated all uses of NULL to nullptr (to be C++11 compliant)bunnei1-7/+7
2014-06-13HLE: Updated various handle debug assertions to be more clear.bunnei1-2/+2
2014-06-13Kernel: Updated several member functions to be constbunnei1-3/+3
2014-06-13Thread: Fixed bug with ResetThread where cpu_registers[15] was being incorrectly setbunnei1-1/+1
2014-06-13Kernel: Made SyncRequest not pure virtual, with a default implementation of error (as this is not required for all kernel objects)bunnei1-10/+0
2014-06-13Kernel: Added real support for thread and event blockingbunnei1-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.
2014-06-02svc: added GetThreadPriority and SetThreadPriority, added (incomplete) DuplicateHandle supportbunnei1-0/+45
2014-06-02kernel: changed main thread priority to default, updated Kernel::Reschedule to use PrepareReschedulebunnei1-3/+3
2014-06-01thread: updated Reschedule to sit at a synchronization barrier when no other threads are ready for executionbunnei1-0/+18
2014-05-27kernel: added WaitSynchronization method to Kernel::Objectbunnei1-0/+11
2014-05-27kernel: updated SyncRequest to take boolean thread wait result as a parameterbunnei1-2/+6
2014-05-27kernel: add a SyncRequest method to KernelObject for use with svcSendSyncRequestbunnei1-0/+5
2014-05-23thread: renamed "WaitCurThread" to "WaitCurrentThread", removed unused "reason" argumentbunnei1-2/+2
2014-05-23thread: removed unused SwitchContext/Reschedule reason field, added missing arg parameter to SVC CreateThreadbunnei1-3/+3
2014-05-23kernel: refactored function naming to remove "__" prefixbunnei1-39/+39
2014-05-23thread: moved ThreadStatus/WaitType to header, added support for arg on CreateThread, added correct CPSR resetbunnei1-34/+15
2014-05-22thread: fixed bug where result of __NextThread was not being properly checked when NULLbunnei1-1/+1
2014-05-21thread: added correct lowest thread priority, added a thread priority check, and added some commentsbunnei1-0/+3
2014-05-21thread: exposed ResumeThreadFromWait function for use in other kernel modulesbunnei1-8/+8
2014-05-21thread: moved threading calls to the Kernel namespacebunnei1-89/+95
2014-05-21ARM_Interface: added SaveContext and LoadContext functions for HLE thread switchingbunnei1-36/+2
2014-05-21renamed "syscall" module to "svc" (more accurate naming)bunnei1-1/+1
2014-05-21thread: whitespace change - fixed * and & placementbunnei1-25/+25
2014-05-21- created a Kernel namespacebunnei1-9/+9
- cleaned up Kernel code a bit (moved stuff into namespace, fixed whitespace issues) - added handle types for all different CTROS handles
2014-05-19- moved Handle/Result definitions to kernel.hbunnei1-2/+0
- added ResetType enum
2014-05-17changed a commentbunnei1-1/+1
2014-05-17- added enum ThreadProcessorIdbunnei1-51/+90
- reorganized some kernel thread functions - added placeholder __KernelWaitThread_Synchronization function
2014-05-17- replaced KERNELOBJECT_MAX_NAME_LENGTH with KERNEL_MAX_NAME_LENGTHbunnei1-4/+5
- added KERNEL_DEFAULT_STACK_SIZE definition (0x4000)
2014-05-16completely gutted/refactored threading code to be simplerbunnei1-616/+228
2014-05-15- added helper function for __KernelCreateThreadbunnei1-4/+70
- added __KernelSwitchToThread for enabling a thread - added __KernelRotateThreadReadyQueue
2014-05-14fixed thread reset to not set stack addressbunnei1-1/+1
2014-05-14various cleanups / remove unused codebunnei1-65/+28
2014-05-14added 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 pointbunnei1-64/+524
2014-05-10added initial kernel/thread modulesbunnei1-0/+228