1

allow vector to be lazy init if alloc not avail

This commit is contained in:
2022-07-24 02:22:43 +02:00
parent a0fd7ea1a4
commit b0b6ec13dc
6 changed files with 54 additions and 41 deletions

View File

@ -11,6 +11,9 @@ void Semaphore::p() {
this->lock.release();
} else {
// Block and manage thread in semaphore queue until it's woken up by v() again
if (!wait_queue.initialized()) { // TODO: I will replace this suboptimal datastructure in the future
wait_queue.reserve();
}
this->wait_queue.push_back(scheduler.get_active());
CPU::disable_int(); // Make sure the block() comes through after releasing the lock

View File

@ -27,7 +27,7 @@ private:
public:
// Konstruktor: Initialisieren des Semaphorzaehlers
Semaphore(int c) : counter(c) {}
Semaphore(int c) : wait_queue(true), counter(c) {}
// 'Passieren': Warten auf das Freiwerden eines kritischen Abschnitts.
void p();