# aliashrafabbasi/batos-os architecture

> Architecture diagram of the GitHub repository aliashrafabbasi/batos-os, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aliashrafabbasi/batos-os
- Repository: https://github.com/aliashrafabbasi/batos-os

## Overview

BATOS is an x86_64 kernel whose implemented workflow is boot handoff, hardware/platform setup, memory and interrupt initialization, then managed task execution through scheduling and lifecycle services. The graph preserves documented architecture stages and sampled process, memory, timer, and console capabilities. Some subsystem internals are unsampled; those connections are shown only when documented or supported by the SOURCE INDEX, with uncertain integration links omitted.

Main entry points: [`kernel/kernel.c`](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/kernel.c) (Kernel startup), [`kernel/runtime/runtime.c`](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/runtime/runtime.c) (Kernel runtime), [`kernel/execution/execution.c`](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/execution/execution.c) (Execution admission), [`kernel/sched/task.c`](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/sched/task.c) (Task management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Boot and platform"]
  node_boot["Boot handoff<br/>[boot.c]"]
  node_kernel["Kernel startup<br/>[kernel.c]"]
  node_platform["Platform discovery<br/>[platform.c]"]
end

subgraph group_hardware["CPU and interrupts"]
  node_acpi["ACPI discovery<br/>[acpi.c]"]
  node_cpu["CPU setup<br/>[cpu.c]"]
  node_irqroute["IRQ routing<br/>[irq_routing.c]"]
  node_controllers["Interrupt controllers<br/>[ioapic.c]"]
  node_interrupts["Interrupt dispatch<br/>[irq.c]"]
end

subgraph group_memory["Memory management"]
  node_pmm["Physical memory<br/>[pmm.c]"]
  node_vmm["Virtual memory<br/>[vmm.c]"]
  node_heap["Kernel heap<br/>[heap.c]"]
end

subgraph group_execution["Processes and scheduling"]
  node_process["Process management<br/>[process.c]"]
  node_task["Task management<br/>[task.c]"]
  node_scheduler["Scheduler<br/>[scheduler.c]"]
  node_execution["Execution admission<br/>[execution.c]"]
  node_lifecycle["Task reclamation<br/>[lifecycle.c]"]
end

subgraph group_services["Kernel services"]
  node_runtime["Kernel runtime<br/>[runtime.c]"]
  node_timers["Timer services<br/>[timer_service.c]"]
  node_console["Console output<br/>[console.c]"]
end

node_bootloader(("Bootloader"))

node_bootloader -->|"hands off"| node_boot
node_boot -->|"provides boot data"| node_kernel
node_kernel -->|"initializes"| node_pmm
node_kernel -->|"initializes"| node_platform
node_kernel -->|"initializes"| node_irqroute
node_kernel -->|"starts"| node_runtime
node_kernel -->|"reports through"| node_console
node_platform -.->|"uses discovery"| node_acpi
node_platform -.->|"configures"| node_controllers
node_irqroute -->|"programs routes"| node_controllers
node_irqroute -->|"sets controller ownership"| node_interrupts
node_pmm -->|"supplies frames"| node_vmm
node_pmm -->|"supplies frames"| node_heap
node_vmm -->|"maps heap memory"| node_heap
node_process -->|"references address spaces"| node_vmm
node_task -->|"maps task stacks"| node_vmm
node_task -->|"joins runnable scheduling"| node_scheduler
node_execution -->|"uses registry"| node_process
node_execution -->|"admits tasks"| node_task
node_execution -->|"registers runnable work"| node_scheduler
node_lifecycle -->|"reclaims resources"| node_task
node_runtime -->|"starts execution"| node_execution
node_runtime -->|"uses lifecycle"| node_lifecycle
node_runtime -->|"initializes timer service"| node_timers
node_runtime -->|"uses output"| node_console

click node_boot "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/boot/boot.c"
click node_kernel "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/kernel.c"
click node_platform "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/platform/platform.c"
click node_acpi "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/acpi/acpi.c"
click node_cpu "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/cpu/cpu.c"
click node_irqroute "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/interrupt/irq_routing.c"
click node_controllers "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/apic/ioapic.c"
click node_interrupts "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/interrupt/irq.c"
click node_pmm "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/mm/pmm/pmm.c"
click node_vmm "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/mm/vmm/vmm.c"
click node_heap "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/mm/heap/heap.c"
click node_process "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/process/process.c"
click node_task "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/sched/task.c"
click node_scheduler "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/sched/scheduler.c"
click node_execution "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/execution/execution.c"
click node_lifecycle "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/lifecycle/lifecycle.c"
click node_runtime "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/runtime/runtime.c"
click node_timers "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/time/timer_service.c"
click node_console "https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/console/console.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_boot,node_kernel,node_platform toneBlue
class node_acpi,node_cpu,node_irqroute,node_controllers,node_interrupts toneAmber
class node_pmm,node_vmm,node_heap toneMint
class node_process,node_task,node_scheduler,node_execution,node_lifecycle toneRose
class node_runtime,node_timers,node_console,node_bootloader toneIndigo
```

## Components

### Boot and platform

- [Boot handoff](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/boot/boot.c): `kernel/boot/boot.c`
- [Kernel startup](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/kernel.c): `kernel/kernel.c`
- [Platform discovery](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/platform/platform.c): `kernel/platform/platform.c`

### CPU and interrupts

- [ACPI discovery](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/acpi/acpi.c): `kernel/arch/x86_64/acpi/acpi.c`
- [CPU setup](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/cpu/cpu.c): `kernel/arch/x86_64/cpu/cpu.c`
- [IRQ routing](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/interrupt/irq_routing.c): `kernel/arch/x86_64/interrupt/irq_routing.c`
- [Interrupt controllers](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/apic/ioapic.c): `kernel/arch/x86_64/apic/ioapic.c`
- [Interrupt dispatch](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/interrupt/irq.c): `kernel/arch/x86_64/interrupt/irq.c`

### Memory management

- [Physical memory](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/mm/pmm/pmm.c): `kernel/mm/pmm/pmm.c`
- [Virtual memory](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/mm/vmm/vmm.c): `kernel/mm/vmm/vmm.c`
- [Kernel heap](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/mm/heap/heap.c): `kernel/mm/heap/heap.c`

### Processes and scheduling

- [Process management](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/process/process.c): `kernel/process/process.c`
- [Task management](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/sched/task.c): `kernel/sched/task.c`
- [Scheduler](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/sched/scheduler.c): `kernel/sched/scheduler.c`
- [Execution admission](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/execution/execution.c): `kernel/execution/execution.c`
- [Task reclamation](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/lifecycle/lifecycle.c): `kernel/lifecycle/lifecycle.c`

### Kernel services

- [Kernel runtime](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/runtime/runtime.c): `kernel/runtime/runtime.c`
- [Timer services](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/arch/x86_64/time/timer_service.c): `kernel/arch/x86_64/time/timer_service.c`
- [Console output](https://github.com/aliashrafabbasi/batos-os/blob/main/kernel/console/console.c): `kernel/console/console.c`

### Other components

- **Bootloader**

## Connections

- Bootloader → Boot handoff: hands off
- Boot handoff → Kernel startup: provides boot data (evidence: `kernel/boot/boot.c`)
- Kernel startup → Physical memory: initializes (evidence: `kernel/kernel.c`)
- Kernel startup → Platform discovery: initializes (evidence: `kernel/kernel.c`)
- Kernel startup → IRQ routing: initializes (evidence: `kernel/kernel.c`)
- Kernel startup → Kernel runtime: starts (evidence: `kernel/kernel.c`)
- Kernel startup → Console output: reports through (evidence: `kernel/kernel.c`)
- Platform discovery → ACPI discovery: uses discovery
- Platform discovery → Interrupt controllers: configures
- IRQ routing → Interrupt controllers: programs routes (evidence: `kernel/arch/x86_64/interrupt/irq_routing.c`)
- IRQ routing → Interrupt dispatch: sets controller ownership (evidence: `kernel/arch/x86_64/interrupt/irq_routing.c`)
- Physical memory → Virtual memory: supplies frames (evidence: `kernel/mm/vmm/vmm.c`)
- Physical memory → Kernel heap: supplies frames (evidence: `kernel/mm/heap/heap.c`)
- Virtual memory → Kernel heap: maps heap memory (evidence: `kernel/mm/heap/heap.c`)
- Process management → Virtual memory: references address spaces (evidence: `kernel/process/process.c`)
- Task management → Virtual memory: maps task stacks (evidence: `kernel/sched/task.c`)
- Task management → Scheduler: joins runnable scheduling (evidence: `kernel/sched/task.c`)
- Execution admission → Process management: uses registry (evidence: `kernel/execution/execution.c`)
- Execution admission → Task management: admits tasks (evidence: `kernel/execution/execution.c`)
- Execution admission → Scheduler: registers runnable work (evidence: `kernel/execution/execution.c`)
- Task reclamation → Task management: reclaims resources (evidence: `kernel/lifecycle/lifecycle.c`)
- Kernel runtime → Execution admission: starts execution (evidence: `kernel/runtime/runtime.c`)
- Kernel runtime → Task reclamation: uses lifecycle (evidence: `kernel/runtime/runtime.c`)
- Kernel runtime → Timer services: initializes timer service (evidence: `kernel/runtime/runtime.c`)
- Kernel runtime → Console output: uses output (evidence: `kernel/runtime/runtime.c`)
