Newer
Older
tree-os / src / kernel / lib / task / osTasks.c
@lukas lukas on 30 May 692 bytes new print system
#include <lib/task/osTasks.h>
#include <lib/task/task.h>
#include <lib/textMode/stdio.h>
#include <stdint.h>
#include <lib/memory/alloc.h>

Task mainTask;
Task printerTask;

void printLoop() {
    while (1) {
        yield();
        Message* message = popMessage(&printerTask);
        if (message == 0x00) {
            continue;
        }
        putChars(message->data, message->size);
        free(message->data);
        free(message);
    }
}

void initOSTasks() {
    setRunningTask(&mainTask);
    createTask(&printerTask, (uint32_t) printLoop, 0x0, 0x0);
    schedule(&printerTask);
    // more tasks . . .
    yields();
}

inline Task* getPrinterTask() {
    return &printerTask;
}