1

update demos

This commit is contained in:
2022-07-22 02:34:15 +02:00
parent 4327789db6
commit 4bd216b594
8 changed files with 12 additions and 26 deletions

View File

@ -72,7 +72,7 @@ void HeapDemo::run() {
allocator.dump_free_memory();
kout << "HEAP_DEMO END ===============================================================" << endl;
kout.unlock();
kout.unlock();
scheduler.exit();
}

View File

@ -16,17 +16,14 @@ void KeyboardDemo::run() {
kout << "Keyboard Demo: " << endl;
kout.lock();
// kout.lock();
kout.clear();
kout << "Info: Die Keyboard Demo sperrt den Output Stream:\n"
<< " Wenn die Preemption Demo laeuft wird diese also erst\n"
<< " fortfahren wenn die Keyboard Demo wieder beendet ist." << endl;
while (true) {
kout << listener.waitForKeyEvent();
kout.flush();
}
kout.unlock();
// kout.unlock();
scheduler.exit();
}

View File

@ -31,7 +31,7 @@ public:
~KeyboardDemo() override {
log << INFO << "Uninitialized KeyboardDemo" << endl;
kevman.unsubscribe(this->listener);
kout.unlock();
// kout.unlock();
}
void run() override;

View File

@ -20,14 +20,15 @@ void PreemptiveLoopThread::run() {
}
void PreemptiveThreadDemo::run() {
kout << "Preemptive Thread Demo" << endl;
kout.clear();
kout << "Preemptive Thread Demo:" << endl;
kout << "Readying LoopThreads" << endl;
for (unsigned int i = 0; i < this->number_of_threads; ++i) {
threads.push_back(scheduler.ready<PreemptiveLoopThread>(i));
scheduler.ready<PreemptiveLoopThread>(i);
}
kout << "Exiting main thread" << endl;
while (listener.waitForKeyEvent() != 'L') {}
scheduler.exit();
}

View File

@ -25,20 +25,12 @@ private:
PreemptiveThreadDemo(const PreemptiveThreadDemo& copy) = delete; // Verhindere Kopieren
unsigned int number_of_threads;
bse::Vector<unsigned int> threads;
KeyEventListener listener;
public:
PreemptiveThreadDemo(unsigned int n) : number_of_threads(n), listener(this->tid) {
PreemptiveThreadDemo(unsigned int n) : number_of_threads(n) {
kout << "Initialized PreemptiveThreadDemo" << endl;
}
~PreemptiveThreadDemo() override {
for (unsigned int tid : threads) {
scheduler.kill(tid);
}
}
// Thread-Startmethode
void run() override;
};

View File

@ -4,7 +4,9 @@
#include "user/lib/mem/UniquePointer.h"
void SmartPointerDemo::run() {
kout.lock();
kout.clear();
kout << "Output is written to log to be able to trace memory allocations/deallocations" << endl;
{
@ -117,5 +119,6 @@ void SmartPointerDemo::run() {
}
log << INFO << "Should be deleted by now..." << endl;
kout.unlock();
scheduler.exit();
}

View File

@ -23,10 +23,6 @@ public:
log << INFO << "Initialized TextDemo" << endl;
}
~TextDemo() override {
log << INFO << "Uninitialized TextDemo" << endl;
}
void run() override;
};

View File

@ -103,9 +103,6 @@ void VectorDemo::run() {
kout << "List contains element: " << dec << i << endl;
}
for (bse::Vector<int>::Iterator it = list.begin(); it != list.end(); ++it) {
}
kout.unlock();
scheduler.exit();
}