Skip to content
Snippets Groups Projects
kernel.c 947 B
Newer Older
#include "priority-q.h"
#include "task-descriptor.h"
#include "kernel.h"

void kernelInit(KernelStruct* Colonel) {
antnh6@gmail.com's avatar
antnh6@gmail.com committed
    int i;
    TD* temp;
antnh6@gmail.com's avatar
antnh6@gmail.com committed
    for (i = 0; i < MAX_NUM_TD; i++) {
        temp = &(Colonel->Tasks[i]);
        temp->TaskID = i;
        temp->ParentID = 0;
        temp->TaskState = Init;
        temp->TaskPriority = Prio0;

        if (i == MAX_NUM_TD-1) temp->NextFree = NULL;
        else temp->NextFree = &(Colonel->Tasks[i+1]);
        temp->NextInPQ = NULL;

        temp->sp = USER_STACK_TOP - (STACK_SIZE*i);
        temp->spsr = 208; // or 0xd0;
        temp->RetVal = 0;
        temp->lr = 0;
    }
    Colonel->FirstFree = &(Colonel->Tasks[0]);
    Colonel->LastFree = &(Colonel->Tasks[MAX_NUM_TD-1]);
    Colonel->NumTDsAvail = MAX_NUM_TD;
    Colonel->Active = NULL;
}


void activate(KernelStruct* Colonel, TD* Active) {
antnh6@gmail.com's avatar
antnh6@gmail.com committed
    kerxit(Active);
void handle(KernelStruct* Colonel,  Request* syscallRequest) {
antnh6@gmail.com's avatar
antnh6@gmail.com committed