Semaphores v0.1

This commit is contained in:
wheremyfoodat 2022-11-17 22:14:56 +02:00
parent 3c55d88fab
commit 7b8cac8d43
6 changed files with 44 additions and 11 deletions

View file

@ -48,6 +48,7 @@ class Kernel {
public:
Handle makeMutex(bool locked = false); // Needs to be public to be accessible to the APT/DSP services
Handle makeSemaphore(u32 initialCount, u32 maximumCount); // Needs to be public to be accessible to the service manager port
private:
void signalArbiter(u32 waitingAddress, s32 threadCount);

View file

@ -118,7 +118,7 @@ struct Thread {
u32 waitingAddress;
// The nanoseconds until a thread wakes up from being asleep or from timing out while waiting on an arbiter
s64 waitingNanoseconds;
u64 waitingNanoseconds;
// The tick this thread went to sleep on
u64 sleepTick;
// For WaitSynchronization: A vector of objects this thread is waiting for
@ -157,6 +157,13 @@ struct Mutex {
Mutex(bool lock = false) : locked(lock) {}
};
struct Semaphore {
u32 initialCount;
u32 maximumCount;
Semaphore(u32 initialCount, u32 maximumCount) : initialCount(initialCount), maximumCount(maximumCount) {}
};
// Generic kernel object class
struct KernelObject {
Handle handle = 0; // A u32 the OS will use to identify objects