Commit Graph

203 Commits (61442d6afba2f7528ddf3bbee64e8c2d86a4f4a8)

Author SHA1 Message Date
Subv bca8916cea Kernel/HLE: Use a mutex to synchronize access to the HLE kernel state between the cpu thread and any other possible threads that might touch the kernel (network thread, etc).
This mutex is acquired in SVC::CallSVC, ie, as soon as the guest application enters the HLE kernel, and should be acquired by the aforementioned threads before modifying kernel structures.
8 years ago
Sebastian Valle 56d718b2a1 Merge pull request #2793 from Subv/replyandreceive
Kernel/SVC: Partially implemented svcReplyAndReceive
8 years ago
Subv b53fa9514f Kernel/SVC: Pass the current thread as a parameter to ClientSession::SendSyncRequest. 8 years ago
Subv 88c93a7436 Kernel/SVC: Partially implemented svcReplyAndReceive.
It behaves mostly as WaitSynchronizationN with wait_all = false, except for IPC buffer translation.

The target thread of an IPC response will now wake up when responding.
IPC buffer translation is currently not implemented.
Error passing back to svcSendSyncRequest is currently not implemented.
8 years ago
Yuri Kunde Schlesner e192d417ec Kernel: Implement AcceptSession SVC 8 years ago
Yuri Kunde Schlesner aa0f3047d3 Kernel: Implement CreateSessionToPort SVC 8 years ago
Yuri Kunde Schlesner f94093d0fd Kernel: Implement CreateSession SVC 8 years ago
Yuri Kunde Schlesner be031989ee Kernel: Move HandleTable to a separate file 8 years ago
Yuri Kunde Schlesner 64ecf81a3c Kernel: Move WaitObject to a separate file
Now that HandleTable doesn't directly depend on WaitObject anymore, this
can be separated from the main kernel.h header.
8 years ago
Yuri Kunde Schlesner 9453223075 Kernel: Removed HandleTable::GetWaitObject
This isn't necessary anymore since plain Get works correctly for
WaitObjects.
8 years ago
Yuri Kunde Schlesner 2cdb40d709 Kernel: Centralize error definitions in errors.h 8 years ago
Yuri Kunde Schlesner 6577bbc3c5 Remove ability to load symbol maps
This was now mostly unused except by thread creation, which used a
symbol of the entrypoint, if available, to name the thread.
8 years ago
Michael Theall 31f9c1ab5d Fix OutputDebugString syscall 8 years ago
Fernando Sahmkow b5dbc6cb98 Refined thread launch on syscore error messages 8 years ago
Subv 0be77c3ae4 Timers: Return an error when calling SetTimer with negative timeouts. 8 years ago
Subv 1ddff14511 Threads: Check the process' resource limit for the max allowed priority when creating a thread and remove the priority clamping code. 8 years ago
Subv f2f2572fed Thread: Added priority range checking to svcSetThreadPriority and removed priority clamping code from Thread::SetPriority. 8 years ago
bunnei b5eac78b43 Merge pull request #2410 from Subv/sleepthread
Don't yield execution in SleepThread(0) if there are no available threads to run
8 years ago
Hyper f0199a17f6 Kernel: Fix SharedMemory objects always returning error when addr = 0 (#2404)
Closes #2400
8 years ago
Subv fc2266130b Kernel: Don't attempt to yield execution in SleepThread(0) if there are no available threads to run.
With this we avoid an useless temporary deschedule of the current thread.
8 years ago
Subv fd95b6ee26 Kernel: Remove Thread::wait_objects_index and use wait_objects to hold all the objects that a thread is waiting on. 8 years ago
Subv cef5f45de2 Kernel: Use different thread statuses when a thread calls WaitSynchronization1 and WaitSynchronizationN with wait_all = true.
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.
8 years ago
Subv d3ff5b91e1 Kernel/Mutex: Propagate thread priority changes to other threads inheriting the priority via mutexes 8 years ago
Subv b6a0355568 Kernel/Mutex: Update a mutex priority when a thread stops waiting on it. 8 years ago
Subv 7abf185390 Kernel/Mutex: Implemented priority inheritance.
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.
8 years ago
Subv e6a7723f2f Kernel: Object ShouldWait and Acquire calls now take a thread as a parameter.
This will be useful when implementing mutex priority inheritance.
8 years ago
Subv 38a90882a4 Kernel/Synch: Do not attempt a reschedule on every syscall.
Not all syscalls should cause reschedules, this commit attempts to remedy that, however, it still does not cover all cases.
8 years ago
bunnei e26fbfd1d7 core: Replace "AppCore" nomenclature with just "CPU". 8 years ago
bunnei 5ac5cbeab7 Address clang-format issues. 8 years ago
bunnei 4fc8b8229e core: Remove HLE module, consolidate code & various cleanups. 8 years ago
bunnei 232ef55c1a core: Consolidate core and system state, remove system module & cleanups. 8 years ago
wwylele 5728e42634 Thread: remove the thread from the thread list when exiting 8 years ago
bunnei cda7210fad Merge pull request #2260 from Subv/scheduling
Threading: Reworked the way our scheduler works.
8 years ago
Subv 016307ae65 Fixed the codestyle to match our clang-format rules. 8 years ago
Subv 5b1edc6ae7 Fixed the codestyle to match our clang-format rules. 8 years ago
Subv 406907d570 Properly remove a thread from its wait_objects' waitlist when it is awoken by a timeout. 8 years ago
Subv 17b29d8865 WaitSynch: Removed unused variables and reduced SharedPtr copies.
Define a variable with the value of the sync timeout error code.

Use a boost::flat_map instead of an unordered_map to hold the equivalence of objects and wait indices in a WaitSynchN call.
8 years ago
Subv f9bcf89510 Use std::move where appropriate. 8 years ago
Subv c93c5a72bb Return an error code when connecting to a saturated port.
The error code was taken from the 3DS kernel.
8 years ago
Subv dd8887c8cf KServerPorts now have an HLE handler "template", which is inherited by all ServerSessions created from it. 8 years ago
Subv bdad00c73f Threading: Added some utility functions and const correctness. 8 years ago
Subv 8634b8cb83 Threading: Reworked the way our scheduler works.
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.
8 years ago
Subv ed210c32b3 Threads do not wait for the server endpoint to call AcceptSession before returning from a ConnectToPort or GetServiceHandle call. 8 years ago
Subv 009b15b3aa A bit of a redesign.
Sessions and Ports are now detached from each other.
HLE services are handled by means of a SessionRequestHandler class, Interface now inherits from this class.
The File and Directory classes are no longer kernel objects, but SessionRequestHandlers instead, bound to a ServerSession when requested.
File::OpenLinkFile now creates a new session pair and binds the File instance to it.
8 years ago
Subv 073653e858 Kernel/IPC: Use Ports and Sessions as the fundamental building block of Inter Process Communication.
All handles obtained via srv::GetServiceHandle or svcConnectToPort are references to ClientSessions.
Service modules will wait on the counterpart of those ClientSessions (Called ServerSessions) using svcReplyAndReceive or svcWaitSynchronization[1|N], and will be awoken when a SyncRequest is performed.

HLE Interfaces are now ClientPorts which override the HandleSyncRequest virtual member function to perform command handling immediately.
8 years ago
wwylele 1c0179ad1b name objects 9 years ago
Emmanuel Gil Peyrot ebdae19fd2 Remove empty newlines in #include blocks.
This makes clang-format useful on those.

Also add a bunch of forgotten transitive includes, which otherwise
prevented compilation.
9 years ago
Emmanuel Gil Peyrot dc8479928c Sources: Run clang-format on everything. 9 years ago
Subv 7b445ddff0 Kernel/SVC: Implemented svcCreatePort. 9 years ago
wwylele 86ea7995ad SVC::WaitSynchronizationN: Reschedule at the end 9 years ago