This commit is contained in:
Simon
2025-07-13 16:34:52 +02:00
parent 68cb30210f
commit 42f2dd6028
4 changed files with 32 additions and 4 deletions

View File

@@ -1,7 +1,29 @@
#include "./semaphore.h"
#include "../interrupt/guard.h"
#include "../thread/scheduler.h"
uint8_t counter;
Queue<Thread> waiting;
Semaphore::Semaphore(unsigned c) {
counter=c;
}
Semaphore::Semaphore(unsigned c) { (void)c; }
void Semaphore::p(Vault &vault) { (void)vault; }
void Semaphore::p(Vault &vault) {
//resource is frei, läuft direkt weiter
if (vault.counter > 0)
vault.counter--;
//else
/// thread block, zu aktueller queue hinzufügen und
// vault.sch.block(this);
}
//release
void Semaphore::v(Vault &vault) {
//Thread* first = waiting.dequeue();
//if (first != nullptr)
// void Scheduler::wakeup(first);
//else
vault.counter++;
}
void Semaphore::v(Vault &vault) { (void)vault; }