Kernel for CS 452

About

We built a kernel for ARM processors from scratch in C (and some assembly). On top of the kernel, we built a model train controller that moved trains, controlled switches on the track, and read sensor data. The point of the controller was to accept user input to move the trains as well as to redirect or stop them to prevent collisions.

Features

// Example concurrent user code
int tid = MyTid(); // Task id system call
int sender, id;
Receive(&sender, &id, sizeof(int)); // block for a message
int reply = 0;
Reply(sender, &reply, sizeof(int)); // reply to sender
    
Concurrent tasks, preemptive context switches (hardware interrupts and system calls), round robin scheduler with 32 priorities, and blocking send, receive, and reply system calls.

// block waiting for a hardware timer interrupt
AwaitEvent(INTR_SOURCE_timer);
// block waiting for a character receieved on UART 1
char data = (char)AwaitEvent(INTR_SOURCE_UARG1_GET);
    
Low level blocking on hardware events.

int clock_server_id = WhoIs("ClockServer");

Delay(100); // Delay 100 ticks (each tick is 10ms)
int time = Time(); // current time in ticks
DelayUntil(time + 100); // Wake up now + 100 ticks later

printf("This works! %d, %s", 3, "yes");
// printf uses Puts and Putc which talk to the I/O server
Puts(COM1, "test"); // send "test" on UART1
int data = Getc(COM2); // Get char from UART2
    
Nameserver, clockserver, and I/O server built using AwaitEvent that provide a higher level of abstraction.

A train controller.

This video demos the train controller stopping the trains when it detects a collision (slightly late).