custom OS + AI
An operating system that understands you.
NeuroOS is a small custom operating system with an AI assistant built into its core. Talk to it in plain English to manage files, memory and tasks.
Try the live demoHow it is built4system layers
3languages: ASM, C, Python
7source files
Features
BOOT
Custom bootloader
Starts the computer and shows the NeuroOS message, written in assembly.
AI
Smart scheduler
Gives CPU time to the tasks you use most, and learns from usage.
ASSIST
Neuro assistant
Understands plain English requests like "how is my memory?".
MEMORY
Memory manager
Gives each program a block of memory and frees it when done.
SHELL
Command shell
Simple commands such as ls, tasks and ai.
PREDICT
Usage predictor
Learns which app you open next and gets ready for it.
Architecture
AI Assistant
ai/assistant.py and ai/usage_predictor.py
ai/assistant.py and ai/usage_predictor.py
Shell
os/shell.c reads commands and runs them
os/shell.c reads commands and runs them
Kernel, Scheduler, Memory
os/kernel.c, scheduler.c and memory.c manage the system
os/kernel.c, scheduler.c and memory.c manage the system
Bootloader
os/boot.asm starts the machine
os/boot.asm starts the machine
Live demo
Type commands below. Try help, ls, tasks or ai how is my memory.
neuro@os:~$
Source code
All 7 project files, shown here.
os/boot.asm
; NeuroOS bootloader (16-bit real mode, NASM)
; Build: nasm -f bin boot.asm -o neuroos.img
[org 0x7c00]
start:
mov si, message ; point SI to the text
call print ; print it
jmp $ ; stop here forever
print:
mov ah, 0x0e ; BIOS teletype function
.next:
lodsb ; load next character into AL
or al, al ; end of string?
jz .done
int 0x10 ; print character
jmp .next
.done:
ret
message db 'NeuroOS booting... AI core ready.', 0
times 510 - ($ - $$) db 0 ; pad to 512 bytes
dw 0xAA55 ; boot signature
os/kernel.c
/* NeuroOS kernel (concept code, simplified for learning) */
#include <stdio.h>
#include "scheduler.h"
int main(void) {
printf("NeuroOS kernel 0.1 started\n");
scheduler_init();
scheduler_add("shell", 5);
scheduler_add("neuro-ai", 3);
scheduler_add("backup", 1);
for (int tick = 0; tick < 6; tick++) {
scheduler_run_tick();
}
return 0;
}
os/scheduler.c
/* AI-style scheduler: tasks that are used more get a higher score */
#include <stdio.h>
#include <string.h>
#include "scheduler.h"
#define MAX_TASKS 8
typedef struct { char name[16]; int priority; int usage; } Task;
static Task tasks[MAX_TASKS];
static int count = 0;
void scheduler_init(void) { count = 0; }
void scheduler_add(const char *name, int priority) {
if (count >= MAX_TASKS) return;
strncpy(tasks[count].name, name, 15);
tasks[count].priority = priority;
tasks[count].usage = 0;
count++;
}
void scheduler_run_tick(void) {
int best = 0, best_score = -1;
for (int i = 0; i < count; i++) {
int score = tasks[i].priority * 2 + tasks[i].usage; /* learns from usage */
if (score > best_score) { best_score = score; best = i; }
}
tasks[best].usage++;
printf("tick: running %s (score %d)\n", tasks[best].name, best_score);
}
os/memory.c
/* NeuroOS memory manager demo: simple block allocator */
#include <stdio.h>
#define TOTAL_BLOCKS 16 /* 16 blocks x 128 KB = 2048 KB */
static int used[TOTAL_BLOCKS];
int mem_alloc(int blocks) {
int run = 0;
for (int i = 0; i < TOTAL_BLOCKS; i++) {
run = used[i] ? 0 : run + 1;
if (run == blocks) {
int start = i - blocks + 1;
for (int j = start; j <= i; j++) used[j] = 1;
return start;
}
}
return -1; /* out of memory */
}
void mem_free(int start, int blocks) {
for (int i = start; i < start + blocks; i++) used[i] = 0;
}
void mem_status(void) {
int n = 0;
printf("[");
for (int i = 0; i < TOTAL_BLOCKS; i++) { printf(used[i] ? "#" : "."); n += used[i]; }
printf("] %d/%d blocks used\n", n, TOTAL_BLOCKS);
}
int main(void) {
int a = mem_alloc(4), b = mem_alloc(6);
printf("shell got block %d, neuro-ai got block %d\n", a, b);
mem_status();
mem_free(a, 4);
mem_status();
return 0;
}
os/shell.c
/* NeuroOS shell demo: reads commands and runs them */
#include <stdio.h>
#include <string.h>
int main(void) {
char line[128];
printf("neuro-sh 0.1 (type help, exit to quit)\n");
while (1) {
printf("neuro@os:~$ ");
if (!fgets(line, sizeof line, stdin)) break;
line[strcspn(line, "\n")] = 0;
if (strcmp(line, "exit") == 0) break;
else if (strcmp(line, "help") == 0) printf("help, about, exit\n");
else if (strcmp(line, "about") == 0) printf("NeuroOS 0.1 - AI learning OS\n");
else if (line[0]) printf("command not found: %s\n", line);
}
return 0;
}
ai/assistant.py
"""Neuro - the NeuroOS assistant (simple intent matching, no libraries needed).
Run: python3 assistant.py
"""
INTENTS = {
"cpu": (["cpu", "slow", "speed"], "CPU load is 23%. Background tasks set to low priority."),
"memory": (["memory", "ram"], "Memory: 412 MB used of 2048 MB."),
"files": (["file", "find", "open"], "Found 4 files in /home."),
"security": (["virus", "secure", "safe"], "Security scan finished. 0 threats found."),
"greeting": (["hello", "hi", "hey"], "Hello! I am Neuro."),
}
def understand(text):
"""Return the best matching intent for the user's text."""
words = text.lower().split()
best, best_hits = None, 0
for name, (keywords, _) in INTENTS.items():
hits = sum(1 for k in keywords if any(k in w for w in words))
if hits > best_hits:
best, best_hits = name, hits
return best
def reply(text):
intent = understand(text)
return INTENTS[intent][1] if intent else "I am still learning. Ask about cpu, memory, files or security."
if __name__ == "__main__":
print("Neuro assistant. Type 'exit' to quit.")
while True:
q = input("you> ")
if q.strip().lower() == "exit":
break
print("neuro>", reply(q))
ai/usage_predictor.py
"""Learns which app you open most and predicts the next one.
Run: python3 usage_predictor.py
"""
from collections import Counter, defaultdict
class UsagePredictor:
def __init__(self):
self.after = defaultdict(Counter) # app -> counts of what came next
self.last = None
def record(self, app):
if self.last:
self.after[self.last][app] += 1
self.last = app
def predict(self, app):
counts = self.after.get(app)
return counts.most_common(1)[0][0] if counts else None
if __name__ == "__main__":
p = UsagePredictor()
for app in ["browser", "notes", "browser", "notes", "browser", "music", "browser", "notes"]:
p.record(app)
print("After 'browser' you usually open:", p.predict("browser"))