# nsg650/polaris architecture

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

- Interactive diagram: https://gitdiagram.com/nsg650/polaris
- Repository: https://github.com/nsg650/polaris

## Overview

This repository is an x86_64 operating-system kernel. Its principal workflow is user code issuing system calls that operate on kernel processes, threads, memory, synchronization, and IPC objects. Architecture code supplies boot, interrupt, timer, and multiprocessor support; memory management and scheduling provide core internal layers. The README is empty, so subsystem coverage follows the source tree and SOURCE INDEX; unverified cross-component links are omitted or marked dashed.

Main entry points: [`src/syscall/dispatch.rs`](https://github.com/nsg650/polaris/blob/trunk/src/syscall/dispatch.rs) (Syscall Dispatch), [`src/mm/virt.rs`](https://github.com/nsg650/polaris/blob/trunk/src/mm/virt.rs) (Address Spaces), [`src/sched/process.rs`](https://github.com/nsg650/polaris/blob/trunk/src/sched/process.rs) (Processes), [`src/arch/x86_64/apic.rs`](https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/apic.rs) (APIC Control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boot["Kernel and Architecture"]
  node_kernel["Kernel Entry<br/>[main.rs]"]
  node_arch_entry["x86 Entry<br/>[entry.rs]"]
  node_acpi["ACPI Discovery<br/>[acpi.rs]"]
  node_apic["APIC Control<br/>[apic.rs]"]
  node_asm["CPU Primitives<br/>[asm.rs]"]
  node_timer["HPET Timer<br/>[hpet.rs]"]
  node_interrupts["Interrupt Handling<br/>[intr.rs]"]
  node_smp["Multiprocessors<br/>[smp.rs]"]
end

subgraph group_memory["Memory Management"]
  node_physical["Physical Memory<br/>[phys.rs]"]
  node_virtual["Address Spaces<br/>[virt.rs]"]
  node_vmb["Memory Objects<br/>[vmb.rs]"]
end

subgraph group_execution["Execution and Objects"]
  node_process["Processes<br/>[process.rs]"]
  node_thread["Threads<br/>[thread.rs]"]
  node_scheduler["Scheduler<br/>[sched.rs]"]
  node_dispatch["Wait Dispatch<br/>[dispatch.rs]"]
  node_handles["Object Handles<br/>[handle.rs]"]
end

subgraph group_interfaces["Kernel Interfaces"]
  node_syscall["Syscall Dispatch<br/>[dispatch.rs]"]
  node_channels["IPC Channels<br/>[channels.rs]"]
  node_locks["Spinlocks<br/>[spinlock.rs]"]
end

node_user(("User Program<br/>[user.c]"))

node_user -.->|"issues calls"| node_syscall
node_kernel -.->|"enters via"| node_arch_entry
node_apic -->|"reads tables"| node_acpi
node_apic -->|"uses primitives"| node_asm
node_apic -->|"uses timer"| node_timer
node_virtual -->|"maps pages from"| node_vmb
node_virtual -->|"allocates pages"| node_physical
node_process -->|"owns address space"| node_virtual
node_process -->|"tracks threads"| node_thread
node_thread -->|"enqueues thread"| node_scheduler
node_scheduler -->|"selects thread"| node_thread
node_dispatch -->|"yields execution"| node_scheduler
node_handles -->|"resolves current process"| node_process
node_syscall -.->|"dispatches IPC"| node_channels
node_syscall -.->|"dispatches memory calls"| node_virtual
node_syscall -.->|"dispatches process calls"| node_process
node_locks -->|"controls interrupts"| node_interrupts
node_channels -->|"uses object handles"| node_handles

click node_user "https://github.com/nsg650/polaris/blob/trunk/user/user.c"
click node_kernel "https://github.com/nsg650/polaris/blob/trunk/src/main.rs"
click node_arch_entry "https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/entry.rs"
click node_acpi "https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/acpi.rs"
click node_apic "https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/apic.rs"
click node_asm "https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/asm.rs"
click node_timer "https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/hpet.rs"
click node_interrupts "https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/intr.rs"
click node_smp "https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/smp.rs"
click node_physical "https://github.com/nsg650/polaris/blob/trunk/src/mm/phys.rs"
click node_virtual "https://github.com/nsg650/polaris/blob/trunk/src/mm/virt.rs"
click node_vmb "https://github.com/nsg650/polaris/blob/trunk/src/mm/vmb.rs"
click node_process "https://github.com/nsg650/polaris/blob/trunk/src/sched/process.rs"
click node_thread "https://github.com/nsg650/polaris/blob/trunk/src/sched/thread.rs"
click node_scheduler "https://github.com/nsg650/polaris/blob/trunk/src/sched/sched.rs"
click node_dispatch "https://github.com/nsg650/polaris/blob/trunk/src/sched/dispatch.rs"
click node_handles "https://github.com/nsg650/polaris/blob/trunk/src/object/handle.rs"
click node_syscall "https://github.com/nsg650/polaris/blob/trunk/src/syscall/dispatch.rs"
click node_channels "https://github.com/nsg650/polaris/blob/trunk/src/ipc/channels.rs"
click node_locks "https://github.com/nsg650/polaris/blob/trunk/src/locks/spinlock.rs"

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_kernel,node_arch_entry,node_acpi,node_apic,node_asm,node_timer,node_interrupts,node_smp,node_user toneBlue
class node_physical,node_virtual,node_vmb toneAmber
class node_process,node_thread,node_scheduler,node_dispatch,node_handles toneMint
class node_syscall,node_channels,node_locks toneRose
```

## Components

### Kernel and Architecture

- [Kernel Entry](https://github.com/nsg650/polaris/blob/trunk/src/main.rs): `src/main.rs`
- [x86 Entry](https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/entry.rs): `src/arch/x86_64/entry.rs`
- [ACPI Discovery](https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/acpi.rs): `src/arch/x86_64/acpi.rs`
- [APIC Control](https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/apic.rs): `src/arch/x86_64/apic.rs`
- [CPU Primitives](https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/asm.rs): `src/arch/x86_64/asm.rs`
- [HPET Timer](https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/hpet.rs): `src/arch/x86_64/hpet.rs`
- [Interrupt Handling](https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/intr.rs): `src/arch/x86_64/intr.rs`
- [Multiprocessors](https://github.com/nsg650/polaris/blob/trunk/src/arch/x86_64/smp.rs): `src/arch/x86_64/smp.rs`

### Memory Management

- [Physical Memory](https://github.com/nsg650/polaris/blob/trunk/src/mm/phys.rs): `src/mm/phys.rs`
- [Address Spaces](https://github.com/nsg650/polaris/blob/trunk/src/mm/virt.rs): `src/mm/virt.rs`
- [Memory Objects](https://github.com/nsg650/polaris/blob/trunk/src/mm/vmb.rs): `src/mm/vmb.rs`

### Execution and Objects

- [Processes](https://github.com/nsg650/polaris/blob/trunk/src/sched/process.rs): `src/sched/process.rs`
- [Threads](https://github.com/nsg650/polaris/blob/trunk/src/sched/thread.rs): `src/sched/thread.rs`
- [Scheduler](https://github.com/nsg650/polaris/blob/trunk/src/sched/sched.rs): `src/sched/sched.rs`
- [Wait Dispatch](https://github.com/nsg650/polaris/blob/trunk/src/sched/dispatch.rs): `src/sched/dispatch.rs`
- [Object Handles](https://github.com/nsg650/polaris/blob/trunk/src/object/handle.rs): `src/object/handle.rs`

### Kernel Interfaces

- [Syscall Dispatch](https://github.com/nsg650/polaris/blob/trunk/src/syscall/dispatch.rs): `src/syscall/dispatch.rs`
- [IPC Channels](https://github.com/nsg650/polaris/blob/trunk/src/ipc/channels.rs): `src/ipc/channels.rs`
- [Spinlocks](https://github.com/nsg650/polaris/blob/trunk/src/locks/spinlock.rs): `src/locks/spinlock.rs`

### Other components

- [User Program](https://github.com/nsg650/polaris/blob/trunk/user/user.c): `user/user.c`

## Connections

- User Program → Syscall Dispatch: issues calls
- Kernel Entry → x86 Entry: enters via
- APIC Control → ACPI Discovery: reads tables (evidence: `src/arch/x86_64/apic.rs`)
- APIC Control → CPU Primitives: uses primitives (evidence: `src/arch/x86_64/apic.rs`)
- APIC Control → HPET Timer: uses timer (evidence: `src/arch/x86_64/apic.rs`)
- Address Spaces → Memory Objects: maps pages from (evidence: `src/mm/virt.rs`)
- Address Spaces → Physical Memory: allocates pages (evidence: `src/mm/virt.rs`)
- Processes → Address Spaces: owns address space (evidence: `src/sched/process.rs`)
- Processes → Threads: tracks threads (evidence: `src/sched/process.rs`)
- Threads → Scheduler: enqueues thread (evidence: `src/sched/thread.rs`)
- Scheduler → Threads: selects thread (evidence: `src/sched/sched.rs`)
- Wait Dispatch → Scheduler: yields execution (evidence: `src/sched/dispatch.rs`)
- Object Handles → Processes: resolves current process (evidence: `src/object/handle.rs`)
- Syscall Dispatch → IPC Channels: dispatches IPC (evidence: `src/syscall/dispatch.rs`)
- Syscall Dispatch → Address Spaces: dispatches memory calls (evidence: `src/syscall/dispatch.rs`)
- Syscall Dispatch → Processes: dispatches process calls (evidence: `src/syscall/dispatch.rs`)
- Spinlocks → Interrupt Handling: controls interrupts (evidence: `src/locks/spinlock.rs`)
- IPC Channels → Object Handles: uses object handles (evidence: `src/ipc/channels.rs`)
