1

update for new list interface

This commit is contained in:
2022-07-17 21:02:33 +02:00
parent d09b862dc3
commit 132eb13431
5 changed files with 33 additions and 33 deletions

View File

@ -54,7 +54,7 @@ void Scheduler::ready(Thread* that) {
// Thread-Wechsel durch PIT verhindern // Thread-Wechsel durch PIT verhindern
cpu.disable_int(); cpu.disable_int();
this->ready_queue.insert(that); this->ready_queue.insert_last(that);
log << DEBUG << "Adding to ready_queue, ID: " << dec << that->tid << endl; log << DEBUG << "Adding to ready_queue, ID: " << dec << that->tid << endl;
cpu.enable_int(); cpu.enable_int();
@ -175,7 +175,7 @@ void Scheduler::yield() {
} }
Thread& next = *(Thread*)this->ready_queue.remove_first(); Thread& next = *(Thread*)this->ready_queue.remove_first();
this->ready_queue.insert(this->get_active()); this->ready_queue.insert_last(this->get_active());
// log << TRACE << "Yielding, ID: " << dec << this->get_active()->tid << " => " << next.tid << endl; // log << TRACE << "Yielding, ID: " << dec << this->get_active()->tid << " => " << next.tid << endl;
@ -220,8 +220,8 @@ void Scheduler::block() {
return; return;
} }
this->block_queue.insert(this->get_active()); // Thread that will be blocked waits in block_queue, so the scheduler can also this->block_queue.insert_last(this->get_active()); // Thread that will be blocked waits in block_queue, so the scheduler can also
// kill blocked threads (for example keyboard demo needs this) // kill blocked threads (for example keyboard demo needs this)
Thread& next = *(Thread*)this->ready_queue.remove_first(); Thread& next = *(Thread*)this->ready_queue.remove_first();
log << TRACE << "Blocking thread, ID: " << dec << this->get_active()->tid << " => " << next.tid << endl; log << TRACE << "Blocking thread, ID: " << dec << this->get_active()->tid << " => " << next.tid << endl;

View File

@ -11,7 +11,7 @@ void Semaphore::p() {
this->lock.release(); this->lock.release();
} else { } else {
// Block and manage thread in semaphore queue until it's woken up by v() again // Block and manage thread in semaphore queue until it's woken up by v() again
this->waitQueue.insert(scheduler.get_active()); this->waitQueue.insert_last(scheduler.get_active());
this->lock.release(); this->lock.release();
scheduler.block(); // Moves to next thread scheduler.block(); // Moves to next thread
} }

View File

@ -7,7 +7,7 @@ void ArrayListDemo::run() {
kout << "Adding elements in order" << endl; kout << "Adding elements in order" << endl;
for (unsigned int i = 0; i < 5; ++i) { for (unsigned int i = 0; i < 5; ++i) {
this->list.insert(i); this->list.insert_last(i);
} }
this->list.print(kout); this->list.print(kout);
@ -22,7 +22,7 @@ void ArrayListDemo::run() {
kout << "Adding elements in order with realloc" << endl; kout << "Adding elements in order with realloc" << endl;
for (unsigned int i = 0; i < 10; ++i) { for (unsigned int i = 0; i < 10; ++i) {
kout << "Add " << dec << i << endl; kout << "Add " << dec << i << endl;
this->list.insert(i); this->list.insert_last(i);
} }
this->list.print(kout); this->list.print(kout);
@ -35,7 +35,7 @@ void ArrayListDemo::run() {
// ============================================================ // ============================================================
for (unsigned int i = 0; i < 5; ++i) { for (unsigned int i = 0; i < 5; ++i) {
this->list.insert(i); this->list.insert_last(i);
} }
this->list.print(kout); this->list.print(kout);
@ -62,14 +62,14 @@ void ArrayListDemo::run() {
// These are the threads // These are the threads
int active = 0; // Idle thread int active = 0; // Idle thread
this->list.insert(1); this->list.insert_last(1);
this->list.insert(2); this->list.insert_last(2);
this->list.insert(3); this->list.insert_last(3);
this->list.print(kout); this->list.print(kout);
kout << "Starting..." << endl; kout << "Starting..." << endl;
for (unsigned int n = 0; n < 10000000; ++n) { for (unsigned int n = 0; n < 1000; ++n) {
this->list.insert(active); this->list.insert_last(active);
active = list.remove_first(); active = list.remove_first();
if (this->list.size() != 3) { if (this->list.size() != 3) {

View File

@ -7,9 +7,9 @@ void LinkedListDemo::run() {
kout << "Adding elements in order" << endl; kout << "Adding elements in order" << endl;
for (unsigned int i = 0; i < 5; ++i) { for (unsigned int i = 0; i < 5; ++i) {
this->list.insert(i); this->list.insert_last(i);
} }
this->list.print(kout); this->list.print(kout); // BUG: Crash
kout << "Removing all elements from the front" << endl; kout << "Removing all elements from the front" << endl;
for (unsigned int i = 0; i < 5; ++i) { for (unsigned int i = 0; i < 5; ++i) {
@ -19,23 +19,23 @@ void LinkedListDemo::run() {
// ============================================================ // ============================================================
kout << "Adding elements in order with realloc" << endl; // kout << "Adding elements in order with realloc" << endl;
for (unsigned int i = 0; i < 10; ++i) { // for (unsigned int i = 0; i < 10; ++i) {
kout << "Add " << dec << i << endl; // kout << "Add " << dec << i << endl;
this->list.insert(i); // this->list.insert_last(i);
} // }
this->list.print(kout); // this->list.print(kout);
kout << "Removing all elements from the back" << endl; // kout << "Removing all elements from the back" << endl;
for (unsigned int i = 0; i < 10; ++i) { // for (unsigned int i = 0; i < 10; ++i) {
this->list.remove_last(); // this->list.remove_last();
} // }
this->list.print(kout); // this->list.print(kout);
// ============================================================ // ============================================================
for (unsigned int i = 0; i < 5; ++i) { for (unsigned int i = 0; i < 5; ++i) {
this->list.insert(i); this->list.insert_last(i);
} }
this->list.print(kout); this->list.print(kout);
@ -62,14 +62,14 @@ void LinkedListDemo::run() {
// These are the threads // These are the threads
int active = 0; // Idle thread int active = 0; // Idle thread
this->list.insert(1); this->list.insert_last(1);
this->list.insert(2); this->list.insert_last(2);
this->list.insert(3); this->list.insert_last(3);
this->list.print(kout); this->list.print(kout);
kout << "Starting..." << endl; kout << "Starting..." << endl;
for (unsigned int n = 0; n < 10000000; ++n) { for (unsigned int n = 0; n < 1000; ++n) {
this->list.insert(active); this->list.insert_last(active);
active = list.remove_first(); active = list.remove_first();
if (this->list.size() != 3) { if (this->list.size() != 3) {

View File

@ -3,7 +3,7 @@
void KeyEventManager::subscribe(KeyEventListener& listener) { void KeyEventManager::subscribe(KeyEventListener& listener) {
log << DEBUG << "Subscribe, Thread ID: " << dec << listener.thread.tid << endl; log << DEBUG << "Subscribe, Thread ID: " << dec << listener.thread.tid << endl;
this->listeners.insert(&listener); this->listeners.insert_last(&listener);
} }
void KeyEventManager::unsubscribe(KeyEventListener& listener) { void KeyEventManager::unsubscribe(KeyEventListener& listener) {