Commit graph

182 commits

Author SHA1 Message Date
Subv
bcad1d6f12 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.
2017-01-04 15:58:50 -05:00
Subv
8503e56689 Kernel/Mutex: Propagate thread priority changes to other threads inheriting the priority via mutexes 2017-01-04 15:58:48 -05:00
Subv
d33885b60b Kernel/Mutex: Update a mutex priority when a thread stops waiting on it. 2017-01-04 15:58:47 -05:00
Subv
4e6369d41d 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.
2017-01-04 15:58:46 -05:00
Subv
90570c153b Kernel: Object ShouldWait and Acquire calls now take a thread as a parameter.
This will be useful when implementing mutex priority inheritance.
2017-01-04 15:58:45 -05:00
Subv
a1718862e3 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.
2017-01-04 15:58:44 -05:00
bunnei
8cfd0762fd core: Replace "AppCore" nomenclature with just "CPU". 2016-12-22 00:27:46 -05:00
bunnei
1fd7cfb69e Address clang-format issues. 2016-12-21 23:48:14 -05:00
bunnei
5d22844f3e core: Remove HLE module, consolidate code & various cleanups. 2016-12-21 23:48:13 -05:00
bunnei
d504f6cf08 core: Consolidate core and system state, remove system module & cleanups. 2016-12-21 23:29:13 -05:00
wwylele
c62bc4e616 Thread: remove the thread from the thread list when exiting 2016-12-17 19:23:52 +02:00
bunnei
034651fa7f Merge pull request #2260 from Subv/scheduling
Threading: Reworked the way our scheduler works.
2016-12-16 00:41:22 -05:00
Subv
3e80a1a1c1 Fixed the codestyle to match our clang-format rules. 2016-12-14 12:45:36 -05:00
Subv
00decc1180 Fixed the codestyle to match our clang-format rules. 2016-12-14 12:35:01 -05:00
Subv
7066deff78 Properly remove a thread from its wait_objects' waitlist when it is awoken by a timeout. 2016-12-10 13:29:31 -05:00
Subv
d4815e828d 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.
2016-12-09 12:23:09 -05:00
Subv
021e732815 Use std::move where appropriate. 2016-12-08 11:06:19 -05:00
Subv
06b2b80d31 Return an error code when connecting to a saturated port.
The error code was taken from the 3DS kernel.
2016-12-05 13:59:57 -05:00
Subv
977039e722 KServerPorts now have an HLE handler "template", which is inherited by all ServerSessions created from it. 2016-12-05 11:02:08 -05:00
Subv
44c59feca6 Threading: Added some utility functions and const correctness. 2016-12-04 09:58:36 -05:00
Subv
5bc10a74f6 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.
2016-12-03 22:38:14 -05:00
Subv
811d684274 Threads do not wait for the server endpoint to call AcceptSession before returning from a ConnectToPort or GetServiceHandle call. 2016-12-01 10:47:06 -05:00
Subv
4f2326c8a9 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.
2016-11-30 23:12:35 -05:00
Subv
302ef594a6 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.
2016-11-30 23:02:05 -05:00
wwylele
d1d4b24f76 name objects 2016-09-22 13:52:52 +08:00
Emmanuel Gil Peyrot
1138ec0d49 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.
2016-09-21 11:15:47 +09:00
Emmanuel Gil Peyrot
628ed4376a Sources: Run clang-format on everything. 2016-09-18 09:38:01 +09:00
Subv
a350b5274f Kernel/SVC: Implemented svcCreatePort. 2016-06-11 08:37:37 -05:00
wwylele
a9073da0fd SVC::WaitSynchronizationN: Reschedule at the end 2016-05-21 18:29:38 +03:00
Jannik Vogel
f39adfffe7 Set fpscr for new threads 2016-05-17 08:59:52 +02:00
Subv
54871800a9 Kernel: Implemented shared memory permissions. 2016-05-12 20:01:26 -05:00
Subv
b53900a6ab Kernel/SharedMemory: Properly implemented shared memory support.
Applications can request the kernel to allocate a piece of the linear heap for them when creating a shared memory object.
Shared memory areas are now properly mapped into the target processes when calling svcMapMemoryBlock.

Removed the APT Shared Font hack as it is no longer needed.
2016-05-12 20:00:32 -05:00
bunnei
fe04d0f1cc Merge pull request #1766 from Subv/log_cpu
Kernel/Threading: Warn when a thread can be scheduled in the Syscore (Core 1)
2016-05-08 15:03:08 -04:00
Subv
bfee7941e3 Kernel/Threading: Warn when a thread can be scheduled in the Syscore (Core 1).
We do not currently implement any cores other than the AppCore (Core 0).
2016-05-07 10:23:03 -05:00
bunnei
86bcd88251 Merge pull request #1647 from mailwl/acu-closeasync
ac:u: stub CloseAsync; align memory size in svc:GetProcessInfo(type=2)
2016-04-30 00:11:08 -04:00
Yuri Kunde Schlesner
2396b01d5d Common: Remove section measurement from profiler (#1731)
This has been entirely superseded by MicroProfile. The rest of the code
can go when a simpler frametime/FPS meter is added to the GUI.
2016-04-29 00:07:10 -07:00
mailwl
b15a0b5419 ac:u: stub CloseAsync; check memory size aling in svc:GetProcessInfo(type=2) 2016-04-21 10:34:45 +03:00
Lioncash
bc06a2c79e svc: Move ResetType enum to the kernel event header 2016-03-12 21:47:41 -05:00
Kloen
c72411acb2 ThreadProcessorId_All on SVC::CreateThread 2016-03-01 12:03:32 +01:00
Subv
d9c4c1622f HLE/SVC: Implement UnmapMemoryBlock.
This implementation will need to be (almost completely) changed when we implement multiprocess support.
2016-01-14 11:29:19 -05:00
Lioncash
4ab2d11182 svc: Remove superfluous printf argument 2015-12-25 14:21:45 -05:00
Lioncash
00ca148685 svc: Fix compilation with LOG_TRACE enabled 2015-12-12 18:14:36 -05:00
Yuri Kunde Schlesner
5bed732b03 Kernel: Implement svcGetSystemInfo
This makes smealum/ctrulib@b96dd51d33 work
with Citra.
2015-11-30 19:49:44 -08:00
Yuri Kunde Schlesner
e5bcc24426 SVC: Advance time when calling GetSystemTick to escape busy-wait loops
Cubic Ninja waited for the frame to end by spinning on a loop calling
GetSystemTick while doing nothing else. Since GetSystemTick doesn't
cause a reschedule (which advances time), this meant that very little
emulated time would pass inside that loop, causing the game to spend
most of the frame burning away CPU.
2015-08-30 00:07:02 -03:00
Yuri Kunde Schlesner
424b0fa646 Integrate the MicroProfile profiling library
This brings goodies such as a configurable user interface and
multi-threaded timeline view.
2015-08-24 22:16:28 -03:00
Yuri Kunde Schlesner
00e9d19f28 Kernel: Implement svcGetProcessInfo in a basic way
This also adds some basic memory usage accounting. These two types are
used by Super Smash Bros. during startup.
2015-08-16 01:03:48 -03:00
Yuri Kunde Schlesner
e34643a3e4 Kernel: Add more infrastructure to support different memory layouts
This adds some structures necessary to support multiple memory regions
in the future. It also adds support for different system memory types
and the new linear heap mapping at 0x30000000.
2015-08-16 01:03:47 -03:00
Yuri Kunde Schlesner
6bb23baf0a Move core/mem_map.{cpp,h} => core/hle/kernel/memory.{cpp,h} 2015-08-16 01:03:46 -03:00
Yuri Kunde Schlesner
8850ade24d Kernel: Properly implement ControlMemory FREE and COMMIT 2015-08-16 01:03:45 -03:00
Yuri Kunde Schlesner
24d7c05c8d Merge pull request #888 from zawata/Warning-Fixes-2
Core\HLE : Fix Warning
2015-07-25 12:55:34 -07:00