[Kernel Add WakeupOneThread

This commit is contained in:
wheremyfoodat 2023-04-29 01:45:30 +03:00
parent 856aaf4440
commit dac77cdc1d
3 changed files with 63 additions and 3 deletions

View file

@ -77,6 +77,12 @@ private:
bool shouldWaitOnObject(KernelObject* object);
void releaseMutex(Mutex* moo);
// Wake up the thread with the highest priority out of all threads in the waitlist
// Returns the index of the woken up thread
// Do not call this function with an empty waitlist!!!
int wakeupOneThread(u64 waitlist, Handle handle);
void wakeupAllThreads(u64 waitlist, Handle handle);
std::optional<Handle> getPortHandle(const char* name);
void deleteObjectData(KernelObject& object);

View file

@ -174,10 +174,11 @@ static const char* kernelObjectTypeToString(KernelObjectType t) {
struct Mutex {
u64 waitlist; // Refer to the getWaitlist function below for documentation
Handle ownerThread = 0; // Index of the thread that holds the mutex if it's locked
Handle handle; // Handle of the mutex itself
u32 lockCount; // Number of times this mutex has been locked by its daddy. 0 = not locked
bool locked;
Mutex(bool lock = false) : locked(lock), waitlist(0), lockCount(lock ? 1 : 0) {}
Mutex(bool lock, Handle handle) : locked(lock), waitlist(0), lockCount(lock ? 1 : 0), handle(handle) {}
};
struct Semaphore {