allow vector to be lazy init if alloc not avail
This commit is contained in:
@ -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
|
||||
|
||||
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user