Commit graph

36 commits

Author SHA1 Message Date
bunnei
6643673f28 WaitSynchronizationN: Refactor to fix several bugs
- 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-21 19:11:47 -05:00
bunnei
aa01c57ae9 Kernel: Separate WaitSynchronization into Wait and Acquire methods. 2015-01-21 19:10:24 -05:00
bunnei
7faf2d8e06 WaitSynchronizationN: Implement return values 2015-01-21 19:09:03 -05:00
bunnei
c22bac6398 Kernel: Added WaitObject and changed "waitable" objects inherit from it. 2015-01-21 18:41:00 -05:00
Yuri Kunde Schlesner
8ad41775cc Kernel: Start using boost::intrusive_ptr for lifetime management 2015-01-09 19:43:52 -02:00
Yuri Kunde Schlesner
9bf8462b96 Thread: Reduce use of Handles and move some funcs to inside the class. 2015-01-09 04:02:15 -02:00
Subv
ea80363cc2 Mutex: Add the calling thread to the waiting list when needed
This will happen when the mutex is already owned by another thread. Should fix some issues with games being stuck due to waiting threads not being awoken.
2015-01-04 12:52:34 -05:00
Yuri Kunde Schlesner
7e2903cb74 Kernel: New handle manager
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-28 11:52:55 -02:00
Yuri Kunde Schlesner
23f2142009 Kernel: Replace GetStaticHandleType by HANDLE_TYPE constants 2014-12-28 11:52:53 -02:00
Yuri Kunde Schlesner
73fba22c01 Rename ObjectPool to HandleTable 2014-12-28 11:52:52 -02:00
purpasmart96
ebfd831ccb License change 2014-12-20 21:20:24 -08:00
Subv
bc318c464b Mutex: Remove some forward declarations
Moved Mutex::WaitSynchronization to the end of the file.
2014-12-07 15:57:28 -05:00
Subv
64128aa61a Mutex: Release all held mutexes when a thread exits. 2014-12-07 15:44:21 -05:00
Subv
e3c8e4901c Mutex: Properly lock the mutex when a thread enters it
Also resume only the next immediate thread waiting for the mutex when it is released, instead of resuming them all.
2014-12-05 23:40:43 -05:00
bunnei
a449e0e11a Mutex: Changed behavior to always release mutex for all threads. 2014-11-26 14:38:42 -05:00
Yuri Kunde Schlesner
22c86824a4 Remove duplicated docs/update them for changed parameters. 2014-11-24 17:08:36 -02:00
Yuri Kunde Schlesner
c2588403c0 HLE: Revamp error handling throrough the HLE code
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-24 17:08:36 -02:00
Emmanuel Gil Peyrot
f5d38649c7 Remove trailing spaces in every file but the ones imported from SkyEye, AOSP or generated 2014-11-19 09:03:07 +00:00
Yuri Kunde Schlesner
d72708c1f5 Add override keyword through the code.
This was automated using `clang-modernize`.
2014-10-26 16:18:05 -02:00
Lioncash
98fa3f7cba Core: Alter the kernel string functions to use std::string instead of const char*.
Most functions already operate on std::strings. This also removes the need to manually null terminate thread names.
2014-08-17 23:12:20 -04:00
bunnei
7a1f813be1 Kernel: Updated Event and Mutex to specify handle that they are blocking for. 2014-08-05 20:14:51 -04:00
bunnei
c95972275e HLE: Updated all uses of NULL to nullptr (to be C++11 compliant) 2014-06-13 09:51:13 -04:00
bunnei
5365ca157d Kernel: Updated various kernel function "name" arguments to be const references. 2014-06-13 09:51:12 -04:00
bunnei
d7363322c7 HLE: Updated various handle debug assertions to be more clear. 2014-06-13 09:51:11 -04:00
bunnei
780a443b08 Mutex: Moved ReleaseMutex iterator declaration to be inside while loop. 2014-06-13 09:51:11 -04:00
bunnei
8cac527c94 Kernel: Updated several member functions to be const 2014-06-13 09:51:10 -04:00
bunnei
f5c7c15434 Kernel: Added real support for thread and event blocking
- 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-13 09:51:02 -04:00
bunnei
b78aff8585 svc: added optional name field to Event and Mutex (used for debugging) 2014-06-02 20:38:34 -04:00
bunnei
d8a2c8c657 mutex: fixed typo in ReleaseMutex 2014-05-29 23:31:01 -04:00
bunnei
2ed6652f10 mutex: added preliminary SyncRequest/WaitSynchronization, added some comments/assertions 2014-05-27 22:42:16 -04:00
bunnei
a432dc8f39 kernel: added WaitSynchronization method to Kernel::Object 2014-05-26 22:17:49 -04:00
bunnei
58a3adcdd2 kernel: updated SyncRequest to take boolean thread wait result as a parameter 2014-05-26 22:12:46 -04:00
bunnei
d73d782ba7 kernel: add a SyncRequest method to KernelObject for use with svcSendSyncRequest 2014-05-26 21:01:27 -04:00
bunnei
d26f3d4c1f kernel: refactored function naming to remove "__" prefix 2014-05-22 19:06:12 -04:00
bunnei
eb537c560a mutex: refactored the interface to code to return a Mutex* handle 2014-05-20 23:23:58 -04:00
bunnei
978e1d4653 mutex: initial commit of HLE module 2014-05-20 23:03:45 -04:00