mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
[Kernel & APT] Mutexes v0.1
This commit is contained in:
parent
41e01bbdd4
commit
3c55d88fab
7 changed files with 51 additions and 8 deletions
|
@ -46,6 +46,10 @@ class Kernel {
|
|||
Handle makeSession(Handle port);
|
||||
Handle makeThread(u32 entrypoint, u32 initialSP, u32 priority, s32 id, u32 arg,ThreadStatus status = ThreadStatus::Dormant);
|
||||
|
||||
public:
|
||||
Handle makeMutex(bool locked = false); // Needs to be public to be accessible to the APT/DSP services
|
||||
|
||||
private:
|
||||
void signalArbiter(u32 waitingAddress, s32 threadCount);
|
||||
void sleepThread(s64 ns);
|
||||
void sleepThreadOnArbiter(u32 waitingAddress);
|
||||
|
|
|
@ -150,6 +150,13 @@ static const char* kernelObjectTypeToString(KernelObjectType t) {
|
|||
}
|
||||
}
|
||||
|
||||
struct Mutex {
|
||||
Handle ownerThread = 0; // Index of the thread that holds the mutex if it's locked
|
||||
bool locked;
|
||||
|
||||
Mutex(bool lock = false) : locked(lock) {}
|
||||
};
|
||||
|
||||
// Generic kernel object class
|
||||
struct KernelObject {
|
||||
Handle handle = 0; // A u32 the OS will use to identify objects
|
||||
|
@ -166,4 +173,8 @@ struct KernelObject {
|
|||
T* getData() {
|
||||
return static_cast<T*>(data);
|
||||
}
|
||||
|
||||
const char* getTypeName() {
|
||||
return kernelObjectTypeToString(type);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue