hopefully added semaphores

This commit is contained in:
Simon
2025-07-14 15:24:46 +02:00
parent 42f2dd6028
commit 9d525a9602
3 changed files with 18 additions and 14 deletions

View File

@@ -12,17 +12,18 @@ 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);
else
//thread block, zu aktueller queue hinzufügen und
waiting.enqueue(*vault.sch.active()); //was is der calling thread
//
}
//release
void Semaphore::v(Vault &vault) {
//Thread* first = waiting.dequeue();
//if (first != nullptr)
// void Scheduler::wakeup(first);
//else
Thread* first = waiting.dequeue();
if (first != nullptr)
vault.sch.ready(first); //wakeup "first" thread
else
vault.counter++;
}