mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-19 20:19:13 +12:00
Semaphores v0.1
This commit is contained in:
parent
3c55d88fab
commit
7b8cac8d43
6 changed files with 44 additions and 11 deletions
|
@ -82,7 +82,8 @@ void Kernel::switchToNextThread() {
|
|||
std::optional<int> newThreadIndex = getNextThread();
|
||||
|
||||
if (!newThreadIndex.has_value()) {
|
||||
Helpers::panic("Kernel tried to switch to the next thread but none found");
|
||||
Helpers::warn("Kernel tried to switch to the next thread but none found. Switching to thread 0\n");
|
||||
switchThread(0);
|
||||
} else {
|
||||
switchThread(newThreadIndex.value());
|
||||
}
|
||||
|
@ -149,6 +150,13 @@ Handle Kernel::makeMutex(bool locked) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
Handle Kernel::makeSemaphore(u32 initialCount, u32 maximumCount) {
|
||||
Handle ret = makeObject(KernelObjectType::Semaphore);
|
||||
objects[ret].data = new Semaphore(initialCount, maximumCount);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Kernel::sleepThreadOnArbiter(u32 waitingAddress) {
|
||||
Thread& t = threads[currentThreadIndex];
|
||||
t.status = ThreadStatus::WaitArbiter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue