test2
Simon 4 months ago
parent 68cb30210f
commit 42f2dd6028

@ -24,9 +24,11 @@ Vault::Vault() {
Guarded::~Guarded() { Guard::leave(); }
Guarded Guard::enter() {
bool status = Core::Interrupt::disable();
epi_flag FOR_CURRENT_CORE = true;
//Core::Interrupt::enable();
Core::Interrupt::restore(status);
global_lock.lock();
return Guarded(global_vault);
}

@ -18,6 +18,7 @@ struct Vault {
// no copy
Vault(const Vault&) = delete;
Vault& operator=(const Vault&) = delete;
uint8_t counter;
};
/*! \brief Lock guard that provides access to the epilogue \ref Vault

@ -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; }

@ -62,6 +62,9 @@ bool Scheduler::isActive(const Thread* thread, unsigned int* cpu) {
return false;
}
bool Scheduler::isEmpty() const { return false; }
void Scheduler::setIdle(IdleThread* that) { (void)that; }

Loading…
Cancel
Save